Skip to content

Commit 5c9ad57

Browse files
committed
[JENKINS-53840] Reproducing unit test
1 parent 8d3bfc1 commit 5c9ad57

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

job-dsl-plugin/src/test/groovy/javaposse/jobdsl/plugin/ScriptRequestGeneratorSpec.groovy

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import javaposse.jobdsl.dsl.DslException
88
import javaposse.jobdsl.dsl.ScriptRequest
99
import org.junit.ClassRule
1010
import org.jvnet.hudson.test.JenkinsRule
11+
import hudson.FilePath
12+
import spock.lang.Requires
1113
import spock.lang.Shared
1214
import spock.lang.Specification
1315
import spock.lang.Unroll
@@ -402,4 +404,26 @@ class ScriptRequestGeneratorSpec extends Specification {
402404
then:
403405
requests.empty
404406
}
407+
408+
@Requires({ os.isWindows() })
409+
def 'allow differing separators in base path of workspace and target (on Windows)'() {
410+
setup:
411+
EnvVars env = new EnvVars()
412+
// input a workspace that has forward slash separators where the target will get backward slashes
413+
String crookedRemote = build.workspace.remote.replace('\\', '/')
414+
FilePath customWorkspace = new FilePath(new FilePath(new File('')), crookedRemote)
415+
ScriptRequestGenerator generator = new ScriptRequestGenerator(customWorkspace, env)
416+
417+
when:
418+
List<ScriptRequest> requests = generator.getScriptRequests('a.groovy', false, null, false, null).toList()
419+
420+
then:
421+
requests.size() == 1
422+
requests[0].body == SCRIPT_A
423+
requests[0].urlRoots.length == 1
424+
requests[0].urlRoots[0].toString() == 'workspace:/'
425+
!requests[0].ignoreExisting
426+
requests[0].scriptPath == getAbsolutePath(build.workspace.child('a.groovy'))
427+
requests[0].relativeScriptPath == 'a.groovy'
428+
}
405429
}

0 commit comments

Comments
 (0)