Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions csharp/ql/integration-tests/all-platforms/autobuild/test.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create()
3 changes: 2 additions & 1 deletion csharp/ql/integration-tests/all-platforms/binlog/test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import commands
import dotnet


@dotnet.xdist_group_if_macos
def test(codeql, csharp):
commands.run(["dotnet", "build", "test.sln", "/bl:test.binlog"])
codeql.database.create(build_mode="none", extractor_option="binlog=test.binlog")
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import commands
import dotnet


@dotnet.xdist_group_if_macos
def test(codeql, csharp):
commands.run(["dotnet", "build", "a/test.csproj", "/bl:a.binlog"])
commands.run(["dotnet", "build", "b/test.csproj", "/bl:b.binlog"])
Expand Down
3 changes: 3 additions & 0 deletions csharp/ql/integration-tests/all-platforms/blazor/test.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(source_root="BlazorTest")
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
import dotnet

@dotnet.xdist_group_if_macos
@pytest.mark.ql_test("DB-CHECK", xfail=True)
def test(codeql, csharp):
codeql.database.create(build_mode="none")
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(source_root="BlazorTest")
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import dotnet


@dotnet.xdist_group_if_macos
def test(codeql, csharp):
os.environ["CODEQL_EXTRACTOR_CSHARP_OPTION_TRAP_COMPRESSION"] = "none"
codeql.database.create(
Expand Down
3 changes: 3 additions & 0 deletions csharp/ql/integration-tests/all-platforms/cshtml/test.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(command="dotnet build")
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(build_mode="none")
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import dotnet


@dotnet.xdist_group_if_macos
def test(codeql, csharp):
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_EXTRACT_WEB_VIEWS"] = "false"
codeql.database.create(build_mode="none")
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(build_mode="none")
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(build_mode="none")
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(_assert_failure=True)
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(_assert_failure=True)
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(_assert_failure=True)
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(command="dotnet build")
4 changes: 4 additions & 0 deletions csharp/ql/integration-tests/all-platforms/dotnet_10/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import dotnet

@dotnet.xdist_group_if_macos
def test1(codeql, csharp):
codeql.database.create()

@dotnet.xdist_group_if_macos
def test2(codeql, csharp):
codeql.database.create(build_mode="none")
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import os
import dotnet

def check_build_out(msg, s):
lines = s.splitlines()
assert (
any (("[build-stdout]" in line) and (msg in line) for line in lines)
), f"The C# tracer did not interpret the dotnet path-to-application command correctly."

@dotnet.xdist_group_if_macos
def test1(codeql, csharp):
codeql.database.create(command="dotnet build")


# This test checks that we don't inject any flags when running the application using `dotnet`
@dotnet.xdist_group_if_macos
def test2(codeql, csharp, cwd):
s = codeql.database.create(
command=[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.init("test-db", source_root=".")
# the tracer configuration should not inject the extra command-line arguments for these commands
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import dotnet


@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(command="dotnet pack -o nugetpackage")
assert os.path.isfile(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import dotnet


@dotnet.xdist_group_if_macos
def test(codeql, csharp):
artifacts = "bin/Temp"
codeql.database.create(command=f"dotnet publish -o {artifacts}")
Expand Down
12 changes: 12 additions & 0 deletions csharp/ql/integration-tests/all-platforms/dotnet_run/test.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,56 @@
import dotnet

def check_build_out(msg, s):
lines = s.splitlines()
assert (
any (("[build-stdout]" in line) and (msg in line) for line in lines)
), "The C# tracer did not interpret the 'dotnet run' command correctly"

# no arguments
@dotnet.xdist_group_if_macos
def test_no_args(codeql, csharp):
s = codeql.database.create(command="dotnet run", _capture="stdout")
check_build_out("Default reply", s)


# no arguments, but `--`
@dotnet.xdist_group_if_macos
def test_no_arg_dash_dash(codeql, csharp):
s = codeql.database.create(command="dotnet run --", _capture="stdout")
check_build_out("Default reply", s)


# one argument, no `--`
@dotnet.xdist_group_if_macos
def test_one_arg_no_dash_dash(codeql, csharp):
s = codeql.database.create(command="dotnet run hello", _capture="stdout")
check_build_out("Default reply", s)


# one argument, but `--`
@dotnet.xdist_group_if_macos
def test_one_arg_dash_dash(codeql, csharp):
s = codeql.database.create(command="dotnet run -- hello", _capture="stdout")
check_build_out("Default reply", s)


# two arguments, no `--`
@dotnet.xdist_group_if_macos
def test_two_args_no_dash_dash(codeql, csharp):
s = codeql.database.create(command="dotnet run hello world", _capture="stdout")
check_build_out("hello, world", s)


# two arguments, and `--`
@dotnet.xdist_group_if_macos
def test_two_args_dash_dash(codeql, csharp):
s = codeql.database.create(command="dotnet run -- hello world", _capture="stdout")
check_build_out("hello, world", s)


# shared compilation enabled; tracer should override by changing the command
# to `dotnet run -p:UseSharedCompilation=true -p:UseSharedCompilation=false -- hello world`
@dotnet.xdist_group_if_macos
def test_shared_compilation(codeql, csharp):
s = codeql.database.create(
command="dotnet run -p:UseSharedCompilation=true -- hello world", _capture="stdout"
Expand All @@ -50,6 +59,7 @@ def test_shared_compilation(codeql, csharp):


# option passed into `dotnet run`
@dotnet.xdist_group_if_macos
def test_option(codeql, csharp):
s = codeql.database.create(
command=["dotnet build", "dotnet run --no-build hello world"], _capture="stdout"
Expand All @@ -58,12 +68,14 @@ def test_option(codeql, csharp):


# two arguments, no '--' (first argument quoted)
@dotnet.xdist_group_if_macos
def test_two_args_no_dash_dash_quote_first(codeql, csharp):
s = codeql.database.create(command='dotnet run "hello world" part2', _capture="stdout")
check_build_out("hello world, part2", s)


# two arguments, no '--' (second argument quoted) and using dotnet to execute dotnet
@dotnet.xdist_group_if_macos
def test_two_args_no_dash_dash_quote_second(codeql, csharp):
s = codeql.database.create(command='dotnet dotnet run hello "world part2"', _capture="stdout")
check_build_out("hello, world part2", s)
3 changes: 3 additions & 0 deletions csharp/ql/integration-tests/all-platforms/msbuild/test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
# force CodeQL to use MSBuild by setting `LGTM_INDEX_MSBUILD_TARGET`
codeql.database.create(_env={"LGTM_INDEX_MSBUILD_TARGET": "Build"})
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(command="dotnet build")
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import dotnet


@dotnet.xdist_group_if_macos
def test(codeql, csharp):
os.environ["CODEQL_EXTRACTOR_CSHARP_OPTION_COMPILER_DIAGNOSTIC_LIMIT"] = "2"
os.environ["CODEQL_EXTRACTOR_CSHARP_OPTION_MESSAGE_LIMIT"] = "5"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import dotnet


@dotnet.xdist_group_if_macos
def test(codeql, csharp):
os.environ["CODEQL_EXTRACTOR_CSHARP_OPTION_BUILDLESS"] = "true"
codeql.database.create()
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(build_mode="none")
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import shutil
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp, cwd):
path = os.path.join(cwd, "dependencies")
os.environ["CODEQL_EXTRACTOR_CSHARP_OPTION_BUILDLESS_DEPENDENCY_DIR"] = path
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
import dotnet

@dotnet.xdist_group_if_macos
def test(codeql, csharp):
codeql.database.create(build_mode="none", _assert_failure=True)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import dotnet


@dotnet.xdist_group_if_macos
def test(codeql, csharp):
# Making sure the reachability test of `nuget.org` succeeds:
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_TIMEOUT"] = "1000"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import dotnet


@dotnet.xdist_group_if_macos
def test(codeql, csharp):
# Making sure the reachability test of `nuget.org` succeeds:
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_TIMEOUT"] = "1000"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import runs_on
import dotnet


@dotnet.xdist_group_if_macos
@runs_on.posix
def test(codeql, csharp):
codeql.database.create(_assert_failure=True)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import runs_on
import dotnet


@dotnet.xdist_group_if_macos
@runs_on.posix
def test(codeql, csharp):
codeql.database.create(_assert_failure=True)
5 changes: 4 additions & 1 deletion csharp/ql/integration-tests/posix/dotnet_test/test.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import runs_on
import dotnet


@dotnet.xdist_group_if_macos
@runs_on.posix
def test_implicit_build_then_run(codeql, csharp):
codeql.database.create(command="dotnet test")


@dotnet.xdist_group_if_macos
@runs_on.posix
def test_explicit_build_then_run(codeql, csharp):
codeql.database.create(command=["dotnet build -o myout", "dotnet test myout/dotnet_test.dll"])


# Explicit build and then run tests using the absolute path.
@dotnet.xdist_group_if_macos
@runs_on.posix
def test_explicit_build_then_run_abs_path(codeql, csharp, cwd):
codeql.database.create(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import runs_on
import dotnet


@dotnet.xdist_group_if_macos
@runs_on.posix
def test_implicit_build_and_test(codeql, csharp):
codeql.database.create(command="dotnet test")


# Explicitly build and then run tests.
@dotnet.xdist_group_if_macos
@runs_on.posix
def test_explicit_build_and_test(codeql, csharp):
# Fix `dotnet test` picking `x64` on arm-based macOS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import runs_on
import dotnet


@dotnet.xdist_group_if_macos
@runs_on.posix
def test(codeql, csharp):
os.environ["PROJECT_TO_BUILD"] = "proj.csproj.no_auto"
Expand Down
3 changes: 3 additions & 0 deletions csharp/ql/integration-tests/posix/query-suite/test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import runs_on
import pytest
import dotnet
from query_suites import *

well_known_query_suites = ['csharp-code-quality.qls', 'csharp-code-quality-extended.qls', 'csharp-security-and-quality.qls', 'csharp-security-extended.qls', 'csharp-code-scanning.qls']

@dotnet.xdist_group_if_macos
@runs_on.posix
@pytest.mark.parametrize("query_suite", well_known_query_suites)
def test(codeql, csharp, check_query_suite, query_suite):
check_query_suite(query_suite)

@dotnet.xdist_group_if_macos
@runs_on.posix
def test_not_included_queries(codeql, csharp, check_queries_not_included):
check_queries_not_included('csharp', well_known_query_suites)
Loading