Skip to content

Commit 5d58561

Browse files
committed
Add test for $PWD. Slight test cleanup.
1 parent 769d8a1 commit 5d58561

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/test/java/com/lookout/jenkins/EnvironmentScriptTest.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void testWithEmptyScript () throws Exception {
2626
assertBuildStatusSuccess(job.project.scheduleBuild2(0).get());
2727
}
2828

29-
final String SCRIPT_SIMPLE_VARIABLES =
29+
final static String SCRIPT_SIMPLE_VARIABLES =
3030
"echo var1=one\n"
3131
+ "echo var2=two\n"
3232
+ "echo var3=three";
@@ -40,15 +40,14 @@ public void testWithSimpleVariables () throws Exception {
4040
assertEquals("three", vars.get("var3"));
4141
}
4242

43-
final String SCRIPT_DEPENDENT_VARIABLES =
43+
final static String SCRIPT_DEPENDENT_VARIABLES =
4444
"echo var1=one\n"
4545
+ "echo var2='$var1 two'\n"
4646
+ "echo var3='yo $var4'\n"
4747
+ "echo var4='three ${var2}'";
4848
public void testWithDependentVariables () throws Exception {
4949
TestJob job = new TestJob(SCRIPT_DEPENDENT_VARIABLES);
50-
Build<?, ?> b = assertBuildStatusSuccess(job.project.scheduleBuild2(0).get());
51-
System.out.println(b.getLog());
50+
assertBuildStatusSuccess(job.project.scheduleBuild2(0).get());
5251

5352
EnvVars vars = job.builder.getEnvVars();
5453
assertEquals("one", vars.get("var1"));
@@ -57,14 +56,13 @@ public void testWithDependentVariables () throws Exception {
5756
assertEquals("three one two", vars.get("var4"));
5857
}
5958

60-
final String SCRIPT_OVERRIDDEN_VARIABLES =
59+
final static String SCRIPT_OVERRIDDEN_VARIABLES =
6160
"echo var1=one\n"
6261
+ "echo var1+something='not one'\n"
6362
+ "echo var2+something='two'";
6463
public void testWithOverridenVariables () throws Exception {
6564
TestJob job = new TestJob(SCRIPT_OVERRIDDEN_VARIABLES);
66-
Build<?, ?> b = assertBuildStatusSuccess(job.project.scheduleBuild2(0).get());
67-
System.out.println(b.getLog());
65+
assertBuildStatusSuccess(job.project.scheduleBuild2(0).get());
6866

6967
EnvVars vars = job.builder.getEnvVars();
7068
assertEquals("not one:one", vars.get("var1"));
@@ -78,4 +76,12 @@ public void testReadingFileFromSCM () throws Exception {
7876
assertBuildStatusSuccess(job.project.scheduleBuild2(0).get());
7977
assertEquals("bar", job.builder.getEnvVars().get("foo_var"));
8078
}
81-
}
79+
80+
public void testWorkingDirectory () throws Exception {
81+
TestJob job = new TestJob("echo hi >was_run");
82+
Build<?, ?> build = assertBuildStatusSuccess(job.project.scheduleBuild2(0).get());
83+
84+
// Make sure that the $PWD of the script is $WORKSPACE.
85+
assertTrue(build.getWorkspace().child("was_run").exists());
86+
}
87+
}

0 commit comments

Comments
 (0)