Skip to content

Commit facaa9d

Browse files
author
Alan Christie
committed
- Adjusts pipeline tester just to optionally expect some output files
(it used to pass in a file extension)
1 parent 5a936f5 commit facaa9d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/groovy/PipelineTester.groovy

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -567,14 +567,15 @@ class Tester {
567567

568568
// Redirect the '-o' option, if there is a '-o' in the command
569569
def oOption = pipelineCommand =~ /$outputRegex/
570-
File testOutputFile = null
570+
File testOutputPath = null
571+
String outputFileBaseName = null // i.e. "output"
571572
if (oOption.count > 0) {
572573

573574
// Construct and make the path for any '-o' output
574-
File testOutputPath =
575-
new File(outputBasePath, "${currentTestFilename}_${section.key}")
575+
testOutputPath = new File(outputBasePath, "${currentTestFilename}_${section.key}")
576576
testOutputPath.mkdir()
577-
testOutputFile = new File(testOutputPath, oOption[0][1])
577+
outputFileBaseName = oOption[0][1]
578+
File testOutputFile = new File(testOutputPath, outputFileBaseName)
578579
info("Out : $testOutputFile")
579580
// Now swap-out the original '-o'...
580581
String redirectedOutputOption = "-o ${testOutputFile.toString()}"
@@ -615,15 +616,16 @@ class Tester {
615616

616617
// If command execution was successful (exit value of 0)
617618
// then:
618-
// - check that the output file was created (if expected)
619+
// - check that an output file was created (if expected)
619620
// - iterate through any optional _see_ values,
620621
// checking that the pipeline log contains the defined text.
621622
boolean validated = true
622623
if (exitValue == 0) {
623624

624-
// Does the output file exist?
625-
if (testOutputFile != null) {
626-
if (!testOutputFile.exists()) {
625+
// Do we expect output files?
626+
if (testOutputPath != null) {
627+
def outputFiles = new FileNameFinder().getFileNames(testOutputPath, "{outputFileBaseName}.*")
628+
if (outputFiles.size() == 0) {
627629
err("Expected output file '$testOutputFile' but it wasn't there")
628630
validated = false
629631
}

0 commit comments

Comments
 (0)