|
13 | 13 |
|
14 | 14 | if any(s == "--help" for s in sys.argv):
|
15 | 15 | print("""Usage:
|
16 |
| -GenerateFlowTestCase.py specsToTest.csv projectPom.xml outdir |
| 16 | +GenerateFlowTestCase.py specsToTest.csv projectPom.xml outdir [--force] |
17 | 17 |
|
18 | 18 | This generates test cases exercising function model specifications found in specsToTest.csv
|
19 | 19 | producing files Test.java, test.ql and test.expected in outdir.
|
|
22 | 22 | Typically this means supplying a skeleton POM <dependencies> section that retrieves whatever jars
|
23 | 23 | contain the needed classes.
|
24 | 24 |
|
| 25 | +If --force is present, existing files may be overwritten. |
| 26 | +
|
25 | 27 | Requirements: `mvn` and `codeql` should both appear on your path.
|
26 | 28 |
|
27 | 29 | After test generation completes, any lines in specsToTest.csv that didn't produce tests are output.
|
28 | 30 | If this happens, check the spelling of class and method names, and the syntax of input and output specifications.
|
29 | 31 | """)
|
30 | 32 | sys.exit(0)
|
31 | 33 |
|
| 34 | +force = False |
| 35 | +if "--force" in sys.argv: |
| 36 | + sys.argv.remove("--force") |
| 37 | + force = True |
| 38 | + |
32 | 39 | if len(sys.argv) != 4:
|
33 |
| - print("Usage: GenerateFlowTestCase.py specsToTest.csv projectPom.xml outdir", file=sys.stderr) |
| 40 | + print( |
| 41 | + "Usage: GenerateFlowTestCase.py specsToTest.csv projectPom.xml outdir [--force]", file=sys.stderr) |
34 | 42 | print("specsToTest.csv should contain CSV rows describing method taint-propagation specifications to test", file=sys.stderr)
|
35 | 43 | print("projectPom.xml should import dependencies sufficient to resolve the types used in specsToTest.csv", file=sys.stderr)
|
36 | 44 | sys.exit(1)
|
|
45 | 53 | resultJava = os.path.join(sys.argv[3], "Test.java")
|
46 | 54 | resultQl = os.path.join(sys.argv[3], "test.ql")
|
47 | 55 |
|
48 |
| -if os.path.exists(resultJava) or os.path.exists(resultQl): |
| 56 | +if not force and (os.path.exists(resultJava) or os.path.exists(resultQl)): |
49 | 57 | print("Won't overwrite existing files '%s' or '%s'" %
|
50 | 58 | (resultJava, resultQl), file=sys.stderr)
|
51 | 59 | sys.exit(1)
|
|
0 commit comments