Skip to content

Commit b1c3915

Browse files
authored
Merge pull request github#14712 from michaelnebel/csharp/tracerdotnettest
C#: Tracer improvement for `dotnet test`
2 parents ab64d9a + 21cb490 commit b1c3915

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

csharp/ql/integration-tests/posix-only/dotnet_test/dotnet_test.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<PropertyGroup>
44
<TargetFramework>net7.0</TargetFramework>
55
<Nullable>enable</Nullable>
6-
76
<IsPackable>false</IsPackable>
87
</PropertyGroup>
98

@@ -14,4 +13,9 @@
1413
<PackageReference Include="coverlet.collector" Version="3.2.0" />
1514
</ItemGroup>
1615

16+
<Target Name="DeleteBinObjFolders" BeforeTargets="Clean">
17+
<RemoveDir Directories=".\bin" />
18+
<RemoveDir Directories=".\obj" />
19+
<RemoveDir Directories=".\myout" />
20+
</Target>
1721
</Project>

csharp/ql/integration-tests/posix-only/dotnet_test/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@
88
# Explicitly build and then run tests.
99
run_codeql_database_create(['dotnet clean', 'rm -rf test-db', 'dotnet build -o myout', 'dotnet test myout/dotnet_test.dll'], test_db="test2-db", lang="csharp")
1010
check_diagnostics(test_db="test2-db")
11+
12+
thisDir = os.path.abspath(os.getcwd())
13+
# Explicit build and then run tests using the absolute path.
14+
run_codeql_database_create(['dotnet clean', 'rm -rf test2-db', 'dotnet build -o myout', f'dotnet test {thisDir}/myout/dotnet_test.dll'], test_db="test3-db", lang="csharp")
15+
check_diagnostics(test_db="test3-db")

csharp/tools/tracing-config.lua

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,15 @@ function RegisterExtractorPack(id)
8080
end
8181
end
8282

83-
-- for `dotnet test`, we should not append `-p:UseSharedCompilation=false` to the command line
84-
-- if an `exe` or `dll` is passed as an argument as the call is forwarded to vstest.
85-
if testMatch and (arg:match('%.exe$') or arg:match('%.dll')) then
86-
match = false
87-
break
88-
end
89-
9083
-- we have found a sub-command, ignore all strings that look like sub-command names from now on
9184
inSubCommandPosition = false
9285
end
86+
-- for `dotnet test`, we should not append `-p:UseSharedCompilation=false` to the command line
87+
-- if an `exe` or `dll` is passed as an argument as the call is forwarded to vstest.
88+
if testMatch and (arg:match('%.exe$') or arg:match('%.dll')) then
89+
match = false
90+
break
91+
end
9392
-- if we see a separator to `dotnet run`, inject just prior to the existing separator
9493
if arg == '--' then
9594
dotnetRunNeedsSeparator = false

0 commit comments

Comments
 (0)