From 899f5aa41769c6b6265c95bd63517b35e760f1fa Mon Sep 17 00:00:00 2001 From: Andrew Mann Date: Mon, 25 Mar 2013 00:35:41 -0500 Subject: [PATCH 1/2] Fix for JENKINS-16942 https://issues.jenkins-ci.org/browse/JENKINS-16942 PrintWriter.println() uses the OS specific line separator. When SecretRewriter rewrites the secret file, the lines are converted to the format of the running OS. The test case does not account for this. Since the test case is coded expecting line endings of \n, this fix converts \r\n to \n before comparing. --- core/src/test/java/hudson/util/SecretRewriterTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/test/java/hudson/util/SecretRewriterTest.groovy b/core/src/test/java/hudson/util/SecretRewriterTest.groovy index d732dcb716..813daf10ec 100644 --- a/core/src/test/java/hudson/util/SecretRewriterTest.groovy +++ b/core/src/test/java/hudson/util/SecretRewriterTest.groovy @@ -52,7 +52,7 @@ class SecretRewriterTest { def f = File.createTempFile("test", "xml", tmp.root) f.text = before sr.rewrite(f,null) - assert after.trim()==f.text.trim() + assert after.replaceAll("\r\n", "\n").trim()==f.text.replaceAll("\r\n", "\n").trim() } String encryptOld(str) { From 398fa74da0cd10d1f405eeeb005a853bb75491cf Mon Sep 17 00:00:00 2001 From: Andrew Mann Date: Mon, 25 Mar 2013 21:08:54 -0500 Subject: [PATCH 2/2] Replace \r\n with system property line.separator Implementing change as suggested by vjuranek --- core/src/test/java/hudson/util/SecretRewriterTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/test/java/hudson/util/SecretRewriterTest.groovy b/core/src/test/java/hudson/util/SecretRewriterTest.groovy index 813daf10ec..9285f0bcdd 100644 --- a/core/src/test/java/hudson/util/SecretRewriterTest.groovy +++ b/core/src/test/java/hudson/util/SecretRewriterTest.groovy @@ -52,7 +52,7 @@ class SecretRewriterTest { def f = File.createTempFile("test", "xml", tmp.root) f.text = before sr.rewrite(f,null) - assert after.replaceAll("\r\n", "\n").trim()==f.text.replaceAll("\r\n", "\n").trim() + assert after.replaceAll(System.getProperty("line.separator"), "\n").trim()==f.text.replaceAll(System.getProperty("line.separator"), "\n").trim() } String encryptOld(str) {