forked from sheehan/job-dsl-gradle-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JobScriptsSpec.groovy
43 lines (35 loc) · 1.02 KB
/
JobScriptsSpec.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.dslexample
import groovy.io.FileType
import javaposse.jobdsl.dsl.DslScriptLoader
import javaposse.jobdsl.dsl.JobManagement
import javaposse.jobdsl.dsl.MemoryJobManagement
import spock.lang.Specification
import spock.lang.Unroll
/**
* Tests that all dsl scripts in the jobs directory will compile.
*/
class JobScriptsSpec extends Specification {
@Unroll
void 'test script #file.name'(File file) {
given:
JobManagement jm = new MemoryJobManagement()
new File('resources').eachFileRecurse(FileType.FILES) {
jm.availableFiles[it.path.replaceAll('\\\\', '/')] = it.text
}
when:
DslScriptLoader.runDslEngine file.text, jm
then:
noExceptionThrown()
where:
file << jobFiles
}
static List<File> getJobFiles() {
List<File> files = []
new File('jobs').eachFileRecurse(FileType.FILES) {
if (it.name.endsWith('.groovy')) {
files << it
}
}
files
}
}