Skip to content

Commit dff9c71

Browse files
committed
Fix test case generation when no auxiliary support functions are required
1 parent c49d525 commit dff9c71

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

java/ql/src/utils/GenerateFlowTestCase.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,17 @@ def getTuples(queryName, jsonResult, fname):
161161

162162
scriptPath = os.path.dirname(sys.argv[0])
163163

164+
def copyfile(fromName, toFileHandle):
165+
with open(os.path.join(scriptPath, fromName), "r") as fromFileHandle:
166+
shutil.copyfileobj(fromFileHandle, toFileHandle)
167+
164168
with open(resultQl, "w") as f:
165-
with open(os.path.join(scriptPath, "testHeader.qlfrag"), "r") as header:
166-
shutil.copyfileobj(header, f)
167-
f.write(", ".join('"%s"' % modelSpecRow[0].strip() for modelSpecRow in supportModelRows))
168-
with open(os.path.join(scriptPath, "testFooter.qlfrag"), "r") as header:
169-
shutil.copyfileobj(header, f)
169+
copyfile("testHeader.qlfrag", f)
170+
if len(supportModelRows) != 0:
171+
copyfile("testModelsHeader.qlfrag", f)
172+
f.write(", ".join('"%s"' % modelSpecRow[0].strip() for modelSpecRow in supportModelRows))
173+
copyfile("testModelsFooter.qlfrag", f)
174+
copyfile("testFooter.qlfrag", f)
170175

171176
# Make an empty .expected file, since this is an inline-exectations test
172177
with open(os.path.join(sys.argv[3], "test.expected"), "w"):

java/ql/src/utils/testFooter.qlfrag

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
]
2-
}
3-
}
41

52
class ValueFlowConf extends DataFlow::Configuration {
63
ValueFlowConf() { this = "qltest:valueFlowConf" }

java/ql/src/utils/testHeader.qlfrag

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,3 @@ import semmle.code.java.dataflow.DataFlow
33
import semmle.code.java.dataflow.ExternalFlow
44
import semmle.code.java.dataflow.TaintTracking
55
import TestUtilities.InlineExpectationsTest
6-
7-
class SummaryModelTest extends SummaryModelCsv {
8-
override predicate row(string row) {
9-
row =
10-
[
11-
//"package;type;overrides;name;signature;ext;inputspec;outputspec;kind",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
]
2+
}
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class SummaryModelTest extends SummaryModelCsv {
2+
override predicate row(string row) {
3+
row =
4+
[
5+
//"package;type;overrides;name;signature;ext;inputspec;outputspec;kind",

0 commit comments

Comments
 (0)