|
43 | 43 | print("Test directory does not contain .cs files. Please specify a working qltest directory.") |
44 | 44 | exit(1) |
45 | 45 |
|
46 | | -cmd = ['odasa', 'selfTest'] |
47 | | -print('Running ' + ' '.join(cmd)) |
48 | | -if subprocess.check_call(cmd): |
49 | | - print("odasa selfTest failed. Ensure odasa is on your current path.") |
50 | | - exit(1) |
51 | | - |
52 | 46 | csharpQueries = os.path.abspath(os.path.dirname(sys.argv[0])) |
53 | 47 | outputFile = os.path.join(testDir, 'stubs.cs') |
54 | 48 |
|
|
58 | 52 | os.remove(outputFile) # It would interfere with the test. |
59 | 53 | print("Removed previous", outputFile) |
60 | 54 |
|
61 | | -cmd = ['odasa', 'qltest', '--optimize', '--leave-temp-files', testDir] |
| 55 | +cmd = ['codeql', 'test', 'run', '--keep-databases', testDir] |
62 | 56 | print('Running ' + ' '.join(cmd)) |
63 | 57 | if subprocess.check_call(cmd): |
64 | | - print("qltest failed. Please fix up the test before proceeding.") |
| 58 | + print("codeql test failed. Please fix up the test before proceeding.") |
65 | 59 | exit(1) |
66 | 60 |
|
67 | | -dbDir = os.path.join(testDir, os.path.basename(testDir) + ".testproj", "db-csharp") |
| 61 | +dbDir = os.path.join(testDir, os.path.basename(testDir) + ".testproj") |
68 | 62 |
|
69 | 63 | if not os.path.isdir(dbDir): |
70 | | - print("Expected database directory " + dbDir + " not found. Please contact Semmle.") |
| 64 | + print("Expected database directory " + dbDir + " not found.") |
71 | 65 | exit(1) |
72 | 66 |
|
73 | | -cmd = ['odasa', 'runQuery', '--query', os.path.join(csharpQueries, 'MinimalStubsFromSource.ql'), '--db', dbDir, '--output-file', outputFile] |
| 67 | +cmd = ['codeql', 'query', 'run', os.path.join( |
| 68 | + csharpQueries, 'MinimalStubsFromSource.ql'), '--database', dbDir, '--output', outputFile] |
74 | 69 | print('Running ' + ' '.join(cmd)) |
75 | 70 | if subprocess.check_call(cmd): |
76 | | - print('Failed to run the query to generate output file. Please contact Semmle.') |
| 71 | + print('Failed to run the query to generate output file.') |
77 | 72 | exit(1) |
78 | 73 |
|
79 | 74 | # Remove the leading " and trailing " bytes from the file |
80 | 75 | len = os.stat(outputFile).st_size |
81 | 76 | f = open(outputFile, "rb") |
82 | 77 | try: |
83 | | - quote = f.read(1) |
84 | | - if quote != b'"': |
85 | | - print("Unexpected character in file. Please contact Semmle.") |
86 | | - contents = f.read(len-3) |
87 | | - quote = f.read(1) |
88 | | - if quote != b'"': |
89 | | - print("Unexpected end character. Please contact Semmle.", quote) |
| 78 | + quote = f.read(6) |
| 79 | + if quote != b"\x02\x01\x86'\x85'": |
| 80 | + print("Unexpected start characters in file.", quote) |
| 81 | + contents = f.read(len-21) |
| 82 | + quote = f.read(15) |
| 83 | + if quote != b'\x0e\x01\x08#select\x01\x01\x00s\x00': |
| 84 | + print("Unexpected end character in file.", quote) |
90 | 85 | finally: |
91 | 86 | f.close() |
92 | 87 |
|
93 | 88 | f = open(outputFile, "wb") |
94 | 89 | f.write(contents) |
95 | 90 | f.close() |
96 | 91 |
|
97 | | -cmd = ['odasa', 'qltest', '--optimize', testDir] |
| 92 | +cmd = ['codeql', 'test', 'run', testDir] |
98 | 93 | print('Running ' + ' '.join(cmd)) |
99 | 94 | if subprocess.check_call(cmd): |
100 | | - print('\nTest failed. You may need to fix up', outputFile) |
101 | | - print('It may help to view', outputFile, ' in Visual Studio') |
102 | | - print("Next steps:") |
103 | | - print('1. Look at the compilation errors, and fix up', outputFile, 'so that the test compiles') |
104 | | - print('2. Re-run odasa qltest --optimize "' + testDir + '"') |
105 | | - print('3. git add "' + outputFile + '"') |
106 | | - exit(1) |
| 95 | + print('\nTest failed. You may need to fix up', outputFile) |
| 96 | + print('It may help to view', outputFile, ' in Visual Studio') |
| 97 | + print("Next steps:") |
| 98 | + print('1. Look at the compilation errors, and fix up', |
| 99 | + outputFile, 'so that the test compiles') |
| 100 | + print('2. Re-run codeql test run "' + testDir + '"') |
| 101 | + print('3. git add "' + outputFile + '"') |
| 102 | + exit(1) |
107 | 103 |
|
108 | 104 | print("\nStub generation successful! Next steps:") |
109 | 105 | print('1. Edit "semmle-extractor-options" in the .cs files to remove unused references') |
|
0 commit comments