Skip to content

Commit 1e7d8ba

Browse files
author
Alan Christie
committed
- Check for duplicate files
- Also does not stop if there's an error at the file-level - Minor tweaks
1 parent f38fd57 commit 1e7d8ba

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/groovy/PipelineTester.groovy

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class Tester {
7474
int testsExecuted = 0
7575
int testsIgnored = 0
7676
def failedTests = []
77+
def observedFiles = []
7778

7879
// The service descriptor for the current test file...
7980
def currentServiceDescriptor = null
@@ -98,7 +99,7 @@ class Tester {
9899

99100
// Find all the potential test files
100101
def testFiles = new FileNameFinder().getFileNames(testSearchDir, testFileSpec)
101-
testFiles.each { path ->
102+
for (String path : testFiles) {
102103

103104
// Reset filename and section number
104105
currentTestFilename = path.split(File.separator)[-1]
@@ -107,6 +108,17 @@ class Tester {
107108
sectionNumber = 0
108109
testScriptVersion = 0
109110

111+
// We must not have duplicate test files -
112+
// this indicates there are pipelines in different projects
113+
// that will clash if combined.
114+
if (observedFiles.contains(currentTestFilename)) {
115+
err("Duplicate pipline ($currentTestFilename)")
116+
recordFailedTest("-")
117+
separate()
118+
continue
119+
}
120+
observedFiles.add(currentTestFilename)
121+
110122
// Guess the Service Descriptor path and filename
111123
// and try to extract the command and the supported options...
112124
String sdFilename = path.take(path.length() - testExt.length()) + sdExt
@@ -122,19 +134,22 @@ class Tester {
122134
if (section_key_lower.equals('version')) {
123135

124136
if (!checkFileVersion(section.value)) {
137+
separate()
125138
err("Unsupported test script version ($section.value)." +
126139
" Expected value from choice of $supportedTestFileVersions")
140+
err("In $path")
127141
recordFailedTest("-")
128-
return false
142+
break
129143
}
130144

131145
} else {
132146

133147
// Must have a version number if we get here...
134148
if (testScriptVersion == 0) {
149+
separate()
135150
err('The file is missing its version definition')
136151
recordFailedTest("-")
137-
return false
152+
break
138153
}
139154

140155
// Section is either a `setup_collect` or `test`...
@@ -144,8 +159,10 @@ class Tester {
144159
} else if (section_key_lower.startsWith(testPrefix)) {
145160
processTest(path, section)
146161
} else if (section_key_lower.startsWith(ignorePrefix)) {
162+
separate()
147163
logTest(path, section)
148164
testsIgnored += 1
165+
info('OK (Ignored)')
149166
}
150167

151168
}
@@ -440,6 +457,7 @@ class Tester {
440457
*/
441458
def processSetupCollection(setupSection) {
442459

460+
separate()
443461
info('Processing setup_collection section')
444462

445463
// Extract key setup values, supplying defaults
@@ -470,8 +488,6 @@ class Tester {
470488
*/
471489
private logTest(path, section) {
472490

473-
separate()
474-
475491
info("Test: $section.key")
476492
info("File: $currentTestFilename")
477493
info("Path: $path")
@@ -504,6 +520,7 @@ class Tester {
504520

505521
testsExecuted += 1
506522

523+
separate()
507524
logTest(filename, section)
508525

509526
def command = section.value['command']
@@ -609,8 +626,6 @@ class Tester {
609626
if (!testOutputFile.exists()) {
610627
err("Expected output file '$testOutputFile' but it wasn't there")
611628
validated = false
612-
} else {
613-
info("Got '$testOutputFile'")
614629
}
615630
}
616631

@@ -630,8 +645,6 @@ class Tester {
630645
if (finder.count == 0) {
631646
err("Expected to see '$see' but it was not in the command's output")
632647
validated = false
633-
} else {
634-
info("Saw '$see'")
635648
}
636649
}
637650
}

0 commit comments

Comments
 (0)