Skip to content

Commit f6c36af

Browse files
committed
C#: Use ConsoleLogger instead og TerminalLogger for test output.
1 parent b4eac1a commit f6c36af

File tree

2 files changed

+18
-0
lines changed
  • csharp/ql/integration-tests/all-platforms

2 files changed

+18
-0
lines changed

csharp/ql/integration-tests/all-platforms/dotnet_build/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1+
import os
2+
13
def check_build_out(msg, s):
24
assert (
35
"[build-stdout] " + msg in s
46
), f"The C# tracer did not interpret the dotnet path-to-application command correctly."
57

8+
def useConsoleLogger():
9+
os.environ["MSBUILDTERMINALLOGGER"]="off"
610

711
def test1(codeql, csharp):
812
codeql.database.create(command="dotnet build")
913

1014

1115
# This test checks that we don't inject any flags when running the application using `dotnet`
1216
def test2(codeql, csharp, cwd):
17+
useConsoleLogger()
1318
s = codeql.database.create(
1419
command=[
1520
"dotnet build -o my_program",

csharp/ql/integration-tests/all-platforms/dotnet_run/test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,58 @@
1+
import os
12
def 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
811
def 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 `--`
1418
def 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 `--`
2025
def 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 `--`
2632
def 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 `--`
3239
def 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 `--`
3846
def 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`
4554
def 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`
5363
def 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)
6172
def 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
6779
def 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

Comments
 (0)