|
1 | 1 | from create_database_utils import *
|
2 | 2 | from diagnostics_test_utils import *
|
3 | 3 |
|
4 |
| -def run_codeql_database_create_stdout(args, dbname): |
5 |
| - stdout = open(dbname + "file.txt", 'w+') |
6 |
| - run_codeql_database_create(args, test_db=dbname, db=None, stdout=stdout, lang="csharp") |
7 |
| - stdout.seek(0) |
8 |
| - s = stdout.read() |
9 |
| - stdout.close() |
10 |
| - return s |
11 |
| - |
12 | 4 | def check_build_out(msg, s):
|
13 | 5 | if "[build-stdout] " + msg not in s:
|
14 |
| - raise Exception("The C# extractor did not interpret the 'dotnet run' command correctly") |
| 6 | + raise Exception("The C# tracer did not interpret the 'dotnet run' command correctly") |
15 | 7 |
|
16 | 8 | # no arguments
|
17 |
| -s = run_codeql_database_create_stdout(['dotnet run'], "test-db") |
| 9 | +s = run_codeql_database_create_stdout(['dotnet run'], "test-db", "csharp") |
18 | 10 | check_build_out("Default reply", s)
|
19 | 11 | check_diagnostics()
|
20 | 12 |
|
21 | 13 | # no arguments, but `--`
|
22 |
| -s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test-db', 'dotnet run --'], "test2-db") |
| 14 | +s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test-db', 'dotnet run --'], "test2-db", "csharp") |
23 | 15 | check_build_out("Default reply", s)
|
24 | 16 | check_diagnostics(test_db="test2-db")
|
25 | 17 |
|
26 | 18 | # one argument, no `--`
|
27 |
| -s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test2-db', 'dotnet run hello'], "test3-db") |
| 19 | +s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test2-db', 'dotnet run hello'], "test3-db", "csharp") |
28 | 20 | check_build_out("Default reply", s)
|
29 | 21 | check_diagnostics(test_db="test3-db")
|
30 | 22 |
|
31 | 23 | # one argument, but `--`
|
32 |
| -s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test3-db', 'dotnet run -- hello'], "test4-db") |
| 24 | +s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test3-db', 'dotnet run -- hello'], "test4-db", "csharp") |
33 | 25 | check_build_out("Default reply", s)
|
34 | 26 | check_diagnostics(test_db="test4-db")
|
35 | 27 |
|
36 | 28 | # two arguments, no `--`
|
37 |
| -s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test4-db', 'dotnet run hello world'], "test5-db") |
| 29 | +s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test4-db', 'dotnet run hello world'], "test5-db", "csharp") |
38 | 30 | check_build_out("hello, world", s)
|
39 | 31 | check_diagnostics(test_db="test5-db")
|
40 | 32 |
|
41 | 33 | # two arguments, and `--`
|
42 |
| -s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test5-db', 'dotnet run -- hello world'], "test6-db") |
| 34 | +s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test5-db', 'dotnet run -- hello world'], "test6-db", "csharp") |
43 | 35 | check_build_out("hello, world", s)
|
44 | 36 | check_diagnostics(test_db="test6-db")
|
45 | 37 |
|
46 | 38 | # shared compilation enabled; tracer should override by changing the command
|
47 | 39 | # to `dotnet run -p:UseSharedCompilation=true -p:UseSharedCompilation=false -- hello world`
|
48 |
| -s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test6-db', 'dotnet run -p:UseSharedCompilation=true -- hello world'], "test7-db") |
| 40 | +s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test6-db', 'dotnet run -p:UseSharedCompilation=true -- hello world'], "test7-db", "csharp") |
49 | 41 | check_build_out("hello, world", s)
|
50 | 42 | check_diagnostics(test_db="test7-db")
|
51 | 43 |
|
52 | 44 | # option passed into `dotnet run`
|
53 |
| -s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test7-db', 'dotnet build', 'dotnet run --no-build hello world'], "test8-db") |
| 45 | +s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test7-db', 'dotnet build', 'dotnet run --no-build hello world'], "test8-db", "csharp") |
54 | 46 | check_build_out("hello, world", s)
|
55 | 47 | check_diagnostics(test_db="test8-db")
|
56 | 48 |
|
57 | 49 | # two arguments, no '--' (first argument quoted)
|
58 |
| -s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test8-db', 'dotnet run "hello world part1" part2'], "test9-db") |
| 50 | +s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test8-db', 'dotnet run "hello world part1" part2'], "test9-db", "csharp") |
59 | 51 | check_build_out("hello world part1, part2", s)
|
60 | 52 | check_diagnostics(test_db="test9-db")
|
61 | 53 |
|
62 | 54 | # two arguments, no '--' (second argument quoted) and using dotnet to execute dotnet
|
63 |
| -s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test9-db', 'dotnet dotnet run part1 "hello world part2"'], "test10-db") |
| 55 | +s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test9-db', 'dotnet dotnet run part1 "hello world part2"'], "test10-db", "csharp") |
64 | 56 | check_build_out("part1, hello world part2", s)
|
65 | 57 | check_diagnostics(test_db="test10-db")
|
0 commit comments