|
10 | 10 |
|
11 | 11 | import sys |
12 | 12 | import os |
| 13 | +import subprocess |
13 | 14 |
|
14 | 15 | print('Script to generate stub.cs files for C# qltest projects') |
15 | 16 |
|
|
42 | 43 | print("Test directory does not contain .cs files. Please specify a working qltest directory.") |
43 | 44 | exit(1) |
44 | 45 |
|
45 | | -cmd = 'odasa selfTest' |
46 | | -print(cmd) |
47 | | -if os.system(cmd): |
| 46 | +cmd = ['odasa', 'selfTest'] |
| 47 | +print('Running ' + ' '.join(cmd)) |
| 48 | +if subprocess.check_call(cmd): |
48 | 49 | print("odasa selfTest failed. Ensure odasa is on your current path.") |
49 | 50 | exit(1) |
50 | 51 |
|
|
57 | 58 | os.remove(outputFile) # It would interfere with the test. |
58 | 59 | print("Removed previous", outputFile) |
59 | 60 |
|
60 | | -cmd = 'odasa qltest --optimize --leave-temp-files "' + testDir + '"' |
61 | | -print(cmd) |
62 | | -if os.system(cmd) != 0: |
| 61 | +cmd = ['odasa', 'qltest', '--optimize', '--leave-temp-files', testDir] |
| 62 | +print('Running ' + ' '.join(cmd)) |
| 63 | +if subprocess.check_call(cmd): |
63 | 64 | print("qltest failed. Please fix up the test before proceeding.") |
64 | 65 | exit(1) |
65 | 66 |
|
|
69 | 70 | print("Expected database directory " + dbDir + " not found. Please contact Semmle.") |
70 | 71 | exit(1) |
71 | 72 |
|
72 | | -cmd = 'odasa runQuery --query "' + os.path.join(csharpQueries, 'MinimalStubsFromSource.ql') + '" --db "' + dbDir +'" --output-file "' + outputFile + '"' |
73 | | -print(cmd) |
74 | | -if os.system(cmd): |
| 73 | +cmd = ['odasa', 'runQuery', '--query', os.path.join(csharpQueries, 'MinimalStubsFromSource.ql'), '--db', dbDir, '--output-file', outputFile] |
| 74 | +print('Running ' + ' '.join(cmd)) |
| 75 | +if subprocess.check_call(cmd): |
75 | 76 | print('Failed to run the query to generate output file. Please contact Semmle.') |
76 | 77 | exit(1) |
77 | 78 |
|
|
93 | 94 | f.write(contents) |
94 | 95 | f.close() |
95 | 96 |
|
96 | | -cmd = 'odasa qltest --optimize "' + testDir + '"' |
97 | | -print(cmd) |
98 | | - |
99 | | -if os.system(cmd): |
| 97 | +cmd = ['odasa', 'qltest', '--optimize', testDir] |
| 98 | +print('Running ' + ' '.join(cmd)) |
| 99 | +if subprocess.check_call(cmd): |
100 | 100 | print('\nTest failed. You may need to fix up', outputFile) |
101 | 101 | print('It may help to view', outputFile, ' in Visual Studio') |
102 | 102 | print("Next steps:") |
|
0 commit comments