Skip to content

Commit 2457284

Browse files
committed
C#: Move helper function to other repo to allow sharing.
1 parent 07fc84d commit 2457284

File tree

1 file changed

+11
-19
lines changed
  • csharp/ql/integration-tests/all-platforms/dotnet_run

1 file changed

+11
-19
lines changed
Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,57 @@
11
from create_database_utils import *
22
from diagnostics_test_utils import *
33

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-
124
def check_build_out(msg, s):
135
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")
157

168
# 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")
1810
check_build_out("Default reply", s)
1911
check_diagnostics()
2012

2113
# 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")
2315
check_build_out("Default reply", s)
2416
check_diagnostics(test_db="test2-db")
2517

2618
# 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")
2820
check_build_out("Default reply", s)
2921
check_diagnostics(test_db="test3-db")
3022

3123
# 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")
3325
check_build_out("Default reply", s)
3426
check_diagnostics(test_db="test4-db")
3527

3628
# 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")
3830
check_build_out("hello, world", s)
3931
check_diagnostics(test_db="test5-db")
4032

4133
# 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")
4335
check_build_out("hello, world", s)
4436
check_diagnostics(test_db="test6-db")
4537

4638
# shared compilation enabled; tracer should override by changing the command
4739
# 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")
4941
check_build_out("hello, world", s)
5042
check_diagnostics(test_db="test7-db")
5143

5244
# 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")
5446
check_build_out("hello, world", s)
5547
check_diagnostics(test_db="test8-db")
5648

5749
# 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")
5951
check_build_out("hello world part1, part2", s)
6052
check_diagnostics(test_db="test9-db")
6153

6254
# 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")
6456
check_build_out("part1, hello world part2", s)
6557
check_diagnostics(test_db="test10-db")

0 commit comments

Comments
 (0)