1+ import os
12def check_build_out (msg , s ):
23 assert (
34 "[build-stdout] " + msg in s
45 ), "The C# tracer did not interpret the 'dotnet run' command correctly"
56
7+ def useConsoleLogger ():
8+ os .environ ["MSBUILDTERMINALLOGGER" ]= "off"
69
710# no arguments
811def test_no_args (codeql , csharp ):
12+ useConsoleLogger ()
913 s = codeql .database .create (command = "dotnet run" , _capture = "stdout" )
1014 check_build_out ("Default reply" , s )
1115
1216
1317# no arguments, but `--`
1418def test_no_arg_dash_dash (codeql , csharp ):
19+ useConsoleLogger ()
1520 s = codeql .database .create (command = "dotnet run --" , _capture = "stdout" )
1621 check_build_out ("Default reply" , s )
1722
1823
1924# one argument, no `--`
2025def test_one_arg_no_dash_dash (codeql , csharp ):
26+ useConsoleLogger ()
2127 s = codeql .database .create (command = "dotnet run hello" , _capture = "stdout" )
2228 check_build_out ("Default reply" , s )
2329
2430
2531# one argument, but `--`
2632def test_one_arg_dash_dash (codeql , csharp ):
33+ useConsoleLogger ()
2734 s = codeql .database .create (command = "dotnet run -- hello" , _capture = "stdout" )
2835 check_build_out ("Default reply" , s )
2936
3037
3138# two arguments, no `--`
3239def test_two_args_no_dash_dash (codeql , csharp ):
40+ useConsoleLogger ()
3341 s = codeql .database .create (command = "dotnet run hello world" , _capture = "stdout" )
3442 check_build_out ("hello, world" , s )
3543
3644
3745# two arguments, and `--`
3846def test_two_args_dash_dash (codeql , csharp ):
47+ useConsoleLogger ()
3948 s = codeql .database .create (command = "dotnet run -- hello world" , _capture = "stdout" )
4049 check_build_out ("hello, world" , s )
4150
4251
4352# shared compilation enabled; tracer should override by changing the command
4453# to `dotnet run -p:UseSharedCompilation=true -p:UseSharedCompilation=false -- hello world`
4554def test_shared_compilation (codeql , csharp ):
55+ useConsoleLogger ()
4656 s = codeql .database .create (
4757 command = "dotnet run -p:UseSharedCompilation=true -- hello world" , _capture = "stdout"
4858 )
@@ -51,6 +61,7 @@ def test_shared_compilation(codeql, csharp):
5161
5262# option passed into `dotnet run`
5363def test_option (codeql , csharp ):
64+ useConsoleLogger ()
5465 s = codeql .database .create (
5566 command = ["dotnet build" , "dotnet run --no-build hello world" ], _capture = "stdout"
5667 )
@@ -59,11 +70,13 @@ def test_option(codeql, csharp):
5970
6071# two arguments, no '--' (first argument quoted)
6172def test_two_args_no_dash_dash_quote_first (codeql , csharp ):
73+ useConsoleLogger ()
6274 s = codeql .database .create (command = 'dotnet run "hello world" part2' , _capture = "stdout" )
6375 check_build_out ("hello world, part2" , s )
6476
6577
6678# two arguments, no '--' (second argument quoted) and using dotnet to execute dotnet
6779def test_two_args_no_dash_dash_quote_second (codeql , csharp ):
80+ useConsoleLogger ()
6881 s = codeql .database .create (command = 'dotnet dotnet run hello "world part2"' , _capture = "stdout" )
6982 check_build_out ("hello, world part2" , s )
0 commit comments