@@ -48,7 +48,7 @@ def main():
48
48
49
49
def bctester (testDir , input_basename , buildenv ):
50
50
""" Loads and parses the input file, runs all tests and reports results"""
51
- input_filename = testDir + "/" + input_basename
51
+ input_filename = os . path . join ( testDir , input_basename )
52
52
raw_data = open (input_filename ).read ()
53
53
input_data = json .loads (raw_data )
54
54
@@ -77,32 +77,36 @@ def bctest(testDir, testObj, buildenv):
77
77
are not as expected. Error is caught by bctester() and reported.
78
78
"""
79
79
# Get the exec names and arguments
80
- execprog = buildenv ["BUILDDIR" ] + "/ src/" + testObj [' exec' ] + buildenv ["EXEEXT" ]
80
+ execprog = os . path . join ( buildenv ["BUILDDIR" ], " src" , testObj [" exec" ] + buildenv ["EXEEXT" ])
81
81
execargs = testObj ['args' ]
82
82
execrun = [execprog ] + execargs
83
83
84
84
# Read the input data (if there is any)
85
85
stdinCfg = None
86
86
inputData = None
87
87
if "input" in testObj :
88
- filename = testDir + "/" + testObj [' input' ]
88
+ filename = os . path . join ( testDir , testObj [" input" ])
89
89
inputData = open (filename ).read ()
90
90
stdinCfg = subprocess .PIPE
91
91
92
92
# Read the expected output data (if there is any)
93
93
outputFn = None
94
94
outputData = None
95
+ outputType = None
95
96
if "output_cmp" in testObj :
96
97
outputFn = testObj ['output_cmp' ]
97
98
outputType = os .path .splitext (outputFn )[1 ][1 :] # output type from file extension (determines how to compare)
98
99
try :
99
- outputData = open (testDir + "/" + outputFn ).read ()
100
+ outputData = open (os . path . join ( testDir , outputFn ) ).read ()
100
101
except :
101
102
logging .error ("Output file " + outputFn + " can not be opened" )
102
103
raise
103
104
if not outputData :
104
105
logging .error ("Output data missing for " + outputFn )
105
106
raise Exception
107
+ if not outputType :
108
+ logging .error ("Output file %s does not have a file extension" % outputFn )
109
+ raise Exception
106
110
107
111
# Run the test
108
112
proc = subprocess .Popen (execrun , stdin = stdinCfg , stdout = subprocess .PIPE , stderr = subprocess .PIPE , universal_newlines = True )
0 commit comments