mirror of
https://github.com/github/codeql.git
synced 2026-01-14 06:54:48 +01:00
Merge pull request #17167 from github/criemen/pytest-csharp
Port C# tests to pytest.
This commit is contained in:
@@ -1,3 +1,2 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create([], lang="csharp")
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import subprocess
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import commands
|
||||
|
||||
subprocess.check_call(["dotnet", "build", "test.sln", "/bl:test.binlog"])
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none", "-Obinlog=test.binlog"])
|
||||
check_diagnostics()
|
||||
|
||||
def test(codeql, csharp):
|
||||
commands.run(["dotnet", "build", "test.sln", "/bl:test.binlog"])
|
||||
codeql.database.create(build_mode="none", extractor_option="binlog=test.binlog")
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from create_database_utils import *
|
||||
import os
|
||||
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_OPTION_TRAP_COMPRESSION"] = "none"
|
||||
|
||||
run_codeql_database_create(['dotnet build /p:DefineConstants=A', 'dotnet build /p:DefineConstants=B'], lang="csharp")
|
||||
def test(codeql, csharp):
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_OPTION_TRAP_COMPRESSION"] = "none"
|
||||
codeql.database.create(
|
||||
command=["dotnet build /p:DefineConstants=A", "dotnet build /p:DefineConstants=B"]
|
||||
)
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(['dotnet build'], lang="csharp")
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(command="dotnet build")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
| Program.cs |
|
||||
| Views/Home/Index.cshtml |
|
||||
| _semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_Views_Home_Index_cshtml.g.cs |
|
||||
| _ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_test_test_Views_Home_Index_cshtml.g.cs |
|
||||
| test-db/working/implicitUsings/GlobalUsings.g.cs |
|
||||
|
||||
@@ -2,15 +2,12 @@ import csharp
|
||||
|
||||
private string getPath(File f) {
|
||||
result = f.getRelativePath() and
|
||||
not exists(
|
||||
result
|
||||
.indexOf("_semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_")
|
||||
)
|
||||
not exists(result.indexOf("_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_"))
|
||||
or
|
||||
exists(int index |
|
||||
index =
|
||||
f.getRelativePath()
|
||||
.indexOf("_semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_") and
|
||||
.indexOf("_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_") and
|
||||
result = f.getRelativePath().substring(index, f.getRelativePath().length())
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(lang="csharp", extra_args=["--build-mode=none"])
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
|
||||
os.environ['CODEQL_EXTRACTOR_CSHARP_BUILDLESS_EXTRACT_WEB_VIEWS'] = 'false'
|
||||
run_codeql_database_create(lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
def test(codeql, csharp):
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_EXTRACT_WEB_VIEWS"] = "false"
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(lang="csharp", extra_args=["--build-mode=none"])
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
| Program.cs |
|
||||
| Views/Home/Index.cshtml |
|
||||
| _semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_net6_Views_Home_Index_cshtml.g.cs |
|
||||
| _ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_net6_test_test_Views_Home_Index_cshtml.g.cs |
|
||||
| test-db/working/implicitUsings/GlobalUsings.g.cs |
|
||||
|
||||
@@ -2,15 +2,12 @@ import csharp
|
||||
|
||||
private string getPath(File f) {
|
||||
result = f.getRelativePath() and
|
||||
not exists(
|
||||
result
|
||||
.indexOf("_semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_")
|
||||
)
|
||||
not exists(result.indexOf("_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_"))
|
||||
or
|
||||
exists(int index |
|
||||
index =
|
||||
f.getRelativePath()
|
||||
.indexOf("_semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_") and
|
||||
.indexOf("_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_") and
|
||||
result = f.getRelativePath().substring(index, f.getRelativePath().length())
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,2 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(lang="csharp", extra_args=["--build-mode=none"])
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully)
|
||||
check_diagnostics()
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(_assert_failure=True)
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully)
|
||||
check_diagnostics()
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(_assert_failure=True)
|
||||
|
||||
@@ -1,5 +1,2 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully)
|
||||
check_diagnostics()
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(_assert_failure=True)
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(['dotnet build'], lang="csharp")
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(command="dotnet build")
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
def check_build_out(msg, s):
|
||||
if "[build-stdout] " + msg not in s:
|
||||
raise Exception("The C# tracer did not interpret the dotnet path-to-application command correctly.")
|
||||
assert (
|
||||
"[build-stdout] " + msg in s
|
||||
), f"The C# tracer did not interpret the dotnet path-to-application command correctly."
|
||||
|
||||
|
||||
def test1(codeql, csharp):
|
||||
codeql.database.create(command="dotnet build")
|
||||
|
||||
run_codeql_database_create(['dotnet build'], test_db="test1-db", lang="csharp")
|
||||
check_diagnostics(test_db="test1-db")
|
||||
|
||||
# This test checks that we don't inject any flags when running the application using `dotnet`
|
||||
my_dir = "my_program"
|
||||
my_abs_path = os.path.abspath(f"{my_dir}/dotnet_build.dll")
|
||||
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test1-db', 'dotnet build -o my_program', f'dotnet {my_abs_path} build is not a subcommand'], "test2-db", "csharp")
|
||||
check_build_out("<arguments>build,is,not,a,subcommand</arguments>", s)
|
||||
check_diagnostics(test_db="test2-db")
|
||||
def test2(codeql, csharp, cwd):
|
||||
s = codeql.database.create(
|
||||
command=[
|
||||
"dotnet build -o my_program",
|
||||
f"dotnet {cwd / 'my_program'}/dotnet_build.dll build is not a subcommand",
|
||||
],
|
||||
_capture="stdout",
|
||||
)
|
||||
|
||||
check_build_out("<arguments>build,is,not,a,subcommand</arguments>", s)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
# the tracer configuration should not inject the extra command-line arguments for these commands
|
||||
# and they should therefore run successfully
|
||||
run_codeql_database_init(lang="csharp")
|
||||
# this command fails on Windows for some reason, so we comment it out for now
|
||||
# run_codeql_database_trace_command(['dotnet', 'tool', 'search', 'publish'])
|
||||
run_codeql_database_trace_command(['dotnet', 'new', 'console', '--force', '--name', 'build', '--output', '.'])
|
||||
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
|
||||
# and they should therefore run successfully
|
||||
# this command fails on Windows for some reason, so we comment it out for now
|
||||
# run_codeql_database_trace_command(['dotnet', 'tool', 'search', 'publish'])
|
||||
codeql.database.trace_command(
|
||||
"test-db", "dotnet", "new", "console", "--force", "--name", "build", "--output", "."
|
||||
)
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
run_codeql_database_create(['dotnet pack -o nugetpackage'], db=None, lang="csharp")
|
||||
|
||||
## Check that the NuGet package is created.
|
||||
if not os.path.isfile("nugetpackage/dotnet_pack.1.0.0.nupkg"):
|
||||
raise Exception("The NuGet package was not created.")
|
||||
|
||||
check_diagnostics()
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(command="dotnet pack -o nugetpackage")
|
||||
assert os.path.isfile(
|
||||
"nugetpackage/dotnet_pack.1.0.0.nupkg"
|
||||
), "The NuGet package was not created."
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
artifacts = 'bin/Temp'
|
||||
run_codeql_database_create([f"dotnet publish -o {artifacts}"], db=None, lang="csharp")
|
||||
|
||||
## Check that the publish folder is created.
|
||||
if not os.path.isdir(artifacts):
|
||||
raise Exception("The publish artifact folder was not created.")
|
||||
|
||||
check_diagnostics()
|
||||
def test(codeql, csharp):
|
||||
artifacts = "bin/Temp"
|
||||
codeql.database.create(command=f"dotnet publish -o {artifacts}")
|
||||
assert os.path.isdir(artifacts), "The publish artifact folder was not created."
|
||||
|
||||
@@ -1,57 +1,69 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
def check_build_out(msg, s):
|
||||
if "[build-stdout] " + msg not in s:
|
||||
raise Exception("The C# tracer did not interpret the 'dotnet run' command correctly")
|
||||
assert (
|
||||
"[build-stdout] " + msg in s
|
||||
), "The C# tracer did not interpret the 'dotnet run' command correctly"
|
||||
|
||||
|
||||
# no arguments
|
||||
s = run_codeql_database_create_stdout(['dotnet run'], "test-db", "csharp")
|
||||
check_build_out("Default reply", s)
|
||||
check_diagnostics()
|
||||
def test_no_args(codeql, csharp):
|
||||
s = codeql.database.create(command="dotnet run", _capture="stdout")
|
||||
check_build_out("Default reply", s)
|
||||
|
||||
|
||||
# no arguments, but `--`
|
||||
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test-db', 'dotnet run --'], "test2-db", "csharp")
|
||||
check_build_out("Default reply", s)
|
||||
check_diagnostics(test_db="test2-db")
|
||||
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 `--`
|
||||
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test2-db', 'dotnet run hello'], "test3-db", "csharp")
|
||||
check_build_out("Default reply", s)
|
||||
check_diagnostics(test_db="test3-db")
|
||||
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 `--`
|
||||
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test3-db', 'dotnet run -- hello'], "test4-db", "csharp")
|
||||
check_build_out("Default reply", s)
|
||||
check_diagnostics(test_db="test4-db")
|
||||
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 `--`
|
||||
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test4-db', 'dotnet run hello world'], "test5-db", "csharp")
|
||||
check_build_out("hello, world", s)
|
||||
check_diagnostics(test_db="test5-db")
|
||||
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 `--`
|
||||
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test5-db', 'dotnet run -- hello world'], "test6-db", "csharp")
|
||||
check_build_out("hello, world", s)
|
||||
check_diagnostics(test_db="test6-db")
|
||||
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`
|
||||
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test6-db', 'dotnet run -p:UseSharedCompilation=true -- hello world'], "test7-db", "csharp")
|
||||
check_build_out("hello, world", s)
|
||||
check_diagnostics(test_db="test7-db")
|
||||
def test_shared_compilation(codeql, csharp):
|
||||
s = codeql.database.create(
|
||||
command="dotnet run -p:UseSharedCompilation=true -- hello world", _capture="stdout"
|
||||
)
|
||||
check_build_out("hello, world", s)
|
||||
|
||||
|
||||
# option passed into `dotnet run`
|
||||
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test7-db', 'dotnet build', 'dotnet run --no-build hello world'], "test8-db", "csharp")
|
||||
check_build_out("hello, world", s)
|
||||
check_diagnostics(test_db="test8-db")
|
||||
def test_option(codeql, csharp):
|
||||
s = codeql.database.create(
|
||||
command=["dotnet build", "dotnet run --no-build hello world"], _capture="stdout"
|
||||
)
|
||||
check_build_out("hello, world", s)
|
||||
|
||||
|
||||
# two arguments, no '--' (first argument quoted)
|
||||
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test8-db', 'dotnet run "hello world part1" part2'], "test9-db", "csharp")
|
||||
check_build_out("hello world part1, part2", s)
|
||||
check_diagnostics(test_db="test9-db")
|
||||
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
|
||||
s = run_codeql_database_create_stdout(['dotnet clean', 'rm -rf test9-db', 'dotnet dotnet run part1 "hello world part2"'], "test10-db", "csharp")
|
||||
check_build_out("part1, hello world part2", s)
|
||||
check_diagnostics(test_db="test10-db")
|
||||
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)
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
# force CodeQL to use MSBuild by setting `LGTM_INDEX_MSBUILD_TARGET`
|
||||
run_codeql_database_create([], db=None, lang="csharp", extra_env={ 'LGTM_INDEX_MSBUILD_TARGET': 'Build' })
|
||||
check_diagnostics()
|
||||
def test(codeql, csharp):
|
||||
# force CodeQL to use MSBuild by setting `LGTM_INDEX_MSBUILD_TARGET`
|
||||
codeql.database.create(_env={"LGTM_INDEX_MSBUILD_TARGET": "Build"})
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(['dotnet build'], lang="csharp")
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(command="dotnet build")
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
os.environ['CODEQL_EXTRACTOR_CSHARP_OPTION_COMPILER_DIAGNOSTIC_LIMIT'] = '2'
|
||||
os.environ['CODEQL_EXTRACTOR_CSHARP_OPTION_MESSAGE_LIMIT'] = '5'
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
check_diagnostics()
|
||||
def test(codeql, csharp):
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_OPTION_COMPILER_DIAGNOSTIC_LIMIT"] = "2"
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_OPTION_MESSAGE_LIMIT"] = "5"
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
os.environ['CODEQL_EXTRACTOR_CSHARP_OPTION_BUILDLESS'] = 'true'
|
||||
run_codeql_database_create([], lang="csharp")
|
||||
|
||||
check_diagnostics()
|
||||
def test(codeql, csharp):
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_OPTION_BUILDLESS"] = "true"
|
||||
codeql.database.create()
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,6 +1,2 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
|
||||
run_codeql_database_create([], db=None, lang="csharp", extra_args=["--build-mode=none"], runFunction=runUnsuccessfully)
|
||||
|
||||
check_diagnostics()
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none", _assert_failure=True)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_EXTRACT_RESOURCES"] = "true"
|
||||
|
||||
run_codeql_database_create(lang="csharp", extra_args=["--build-mode=none"])
|
||||
def test(codeql, csharp):
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_EXTRACT_RESOURCES"] = "true"
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
from create_database_utils import *
|
||||
|
||||
run_codeql_database_create(lang="csharp", extra_args=["--build-mode=none"])
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
These tests are still run with the legacy test runner
|
||||
@@ -183,25 +183,19 @@
|
||||
| 182 | /warnaserror- |
|
||||
| 183 | /utf8output |
|
||||
| 184 | /deterministic+ |
|
||||
| 185 | /sourcelink:obj/Debug/net8.0/test.sourcelink.json |
|
||||
| 186 | /langversion:12.0 |
|
||||
| 187 | /embed:Program.cs |
|
||||
| 188 | /embed:obj/Debug/net8.0/test.GlobalUsings.g.cs |
|
||||
| 189 | /embed:"obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs" |
|
||||
| 190 | /embed:obj/Debug/net8.0/test.AssemblyInfo.cs |
|
||||
| 191 | /analyzerconfig:/home/runner/work/semmle-code/semmle-code/.editorconfig |
|
||||
| 192 | /analyzerconfig:obj/Debug/net8.0/test.GeneratedMSBuildEditorConfig.editorconfig |
|
||||
| 193 | /analyzerconfig:[...]/8.0.101/Sdks/Microsoft.NET.Sdk/analyzers/build/config/analysislevel_8_default.globalconfig |
|
||||
| 194 | /analyzer:[...]/8.0.101/Sdks/Microsoft.NET.Sdk/targets/../analyzers/Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll |
|
||||
| 195 | /analyzer:[...]/8.0.101/Sdks/Microsoft.NET.Sdk/targets/../analyzers/Microsoft.CodeAnalysis.NetAnalyzers.dll |
|
||||
| 196 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/Microsoft.Interop.ComInterfaceGenerator.dll |
|
||||
| 197 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/Microsoft.Interop.JavaScript.JSImportGenerator.dll |
|
||||
| 198 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/Microsoft.Interop.LibraryImportGenerator.dll |
|
||||
| 199 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/Microsoft.Interop.SourceGeneration.dll |
|
||||
| 200 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/System.Text.Json.SourceGeneration.dll |
|
||||
| 201 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/System.Text.RegularExpressions.Generator.dll |
|
||||
| 202 | Program.cs |
|
||||
| 203 | obj/Debug/net8.0/test.GlobalUsings.g.cs |
|
||||
| 204 | obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs |
|
||||
| 205 | obj/Debug/net8.0/test.AssemblyInfo.cs |
|
||||
| 206 | /warnaserror+:NU1605,SYSLIB0011 |
|
||||
| 185 | /langversion:12.0 |
|
||||
| 186 | /analyzerconfig:obj/Debug/net8.0/test.GeneratedMSBuildEditorConfig.editorconfig |
|
||||
| 187 | /analyzerconfig:[...]/8.0.101/Sdks/Microsoft.NET.Sdk/analyzers/build/config/analysislevel_8_default.globalconfig |
|
||||
| 188 | /analyzer:[...]/8.0.101/Sdks/Microsoft.NET.Sdk/targets/../analyzers/Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll |
|
||||
| 189 | /analyzer:[...]/8.0.101/Sdks/Microsoft.NET.Sdk/targets/../analyzers/Microsoft.CodeAnalysis.NetAnalyzers.dll |
|
||||
| 190 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/Microsoft.Interop.ComInterfaceGenerator.dll |
|
||||
| 191 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/Microsoft.Interop.JavaScript.JSImportGenerator.dll |
|
||||
| 192 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/Microsoft.Interop.LibraryImportGenerator.dll |
|
||||
| 193 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/Microsoft.Interop.SourceGeneration.dll |
|
||||
| 194 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/System.Text.Json.SourceGeneration.dll |
|
||||
| 195 | /analyzer:[...]/8.0.1/analyzers/dotnet/cs/System.Text.RegularExpressions.Generator.dll |
|
||||
| 196 | Program.cs |
|
||||
| 197 | obj/Debug/net8.0/test.GlobalUsings.g.cs |
|
||||
| 198 | obj/Debug/net8.0/.NETCoreApp,Version=v8.0.AssemblyAttributes.cs |
|
||||
| 199 | obj/Debug/net8.0/test.AssemblyInfo.cs |
|
||||
| 200 | /warnaserror+:NU1605,SYSLIB0011 |
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], lang="csharp")
|
||||
|
||||
@runs_on.linux
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create()
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
path = b'\xd2abcd.cs'
|
||||
|
||||
with open(path, 'w') as file:
|
||||
file.write('class X { }\n')
|
||||
@runs_on.linux
|
||||
def test(codeql, csharp):
|
||||
path = b"\xd2abcd.cs"
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
with open(path, "w") as file:
|
||||
file.write("class X { }\n")
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully)
|
||||
check_diagnostics()
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(_assert_failure=True)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully)
|
||||
check_diagnostics()
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(_assert_failure=True)
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import runs_on
|
||||
|
||||
# Implicitly build and then run tests.
|
||||
run_codeql_database_create(['dotnet test'], test_db="test-db", lang="csharp")
|
||||
check_diagnostics()
|
||||
|
||||
# Explicitly build and then run tests.
|
||||
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")
|
||||
check_diagnostics(test_db="test2-db")
|
||||
@runs_on.posix
|
||||
def test_implicit_build_then_run(codeql, csharp):
|
||||
codeql.database.create(command="dotnet test")
|
||||
|
||||
|
||||
@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"])
|
||||
|
||||
|
||||
thisDir = os.path.abspath(os.getcwd())
|
||||
# Explicit build and then run tests using the absolute path.
|
||||
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")
|
||||
check_diagnostics(test_db="test3-db")
|
||||
@runs_on.posix
|
||||
def test_explicit_build_then_run_abs_path(codeql, csharp, cwd):
|
||||
codeql.database.create(
|
||||
command=["dotnet build -o myout", f"dotnet test {cwd}/myout/dotnet_test.dll"]
|
||||
)
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
import platform
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import runs_on
|
||||
|
||||
# Implicitly build and then run tests.
|
||||
run_codeql_database_create(['dotnet test'], test_db="test-db", lang="csharp")
|
||||
check_diagnostics()
|
||||
|
||||
# Fix `dotnet test` picking `x64` on arm-based macOS
|
||||
architecture = '-a arm64' if platform.machine() == 'arm64' else ''
|
||||
@runs_on.posix
|
||||
def test_implicit_build_and_test(codeql, csharp):
|
||||
codeql.database.create(command="dotnet test")
|
||||
|
||||
|
||||
# Explicitly build and then run tests.
|
||||
run_codeql_database_create(['dotnet clean', 'rm -rf test-db', 'dotnet build -o myout --os win', 'dotnet test myout/dotnet_test_mstest.exe ' + architecture], test_db="test2-db", lang="csharp")
|
||||
check_diagnostics(test_db="test2-db")
|
||||
@runs_on.posix
|
||||
def test_explicit_build_and_test(codeql, csharp):
|
||||
# Fix `dotnet test` picking `x64` on arm-based macOS
|
||||
architecture = "-a arm64" if runs_on.arm64 else ""
|
||||
codeql.database.create(
|
||||
command=[
|
||||
"dotnet build -o myout --os win",
|
||||
f"dotnet test myout/dotnet_test_mstest.exe {architecture}",
|
||||
]
|
||||
)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import os
|
||||
import runs_on
|
||||
|
||||
os.environ["PROJECT_TO_BUILD"] = "proj.csproj.no_auto"
|
||||
|
||||
run_codeql_database_create([], db=None, lang="csharp")
|
||||
check_diagnostics()
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
os.environ["PROJECT_TO_BUILD"] = "proj.csproj.no_auto"
|
||||
codeql.database.create()
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Skipping the test on the ARM runners, as we're running into trouble with Mono and nuget.
|
||||
@@ -1,5 +1,12 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
import pytest
|
||||
import os
|
||||
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_DOTNET_FRAMEWORK_REFERENCES"] = "/non-existent-path"
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
# Skipping the test on the ARM runners, as we're running into trouble with Mono and nuget.
|
||||
@pytest.mark.only_if(runs_on.linux or (runs_on.macos and runs_on.x86_64))
|
||||
def test(codeql, csharp):
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_DOTNET_FRAMEWORK_REFERENCES"] = (
|
||||
"/non-existent-path"
|
||||
)
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Skipping the test on the ARM runners, as we're running into trouble with Mono and nuget.
|
||||
@@ -1,8 +1,12 @@
|
||||
from create_database_utils import *
|
||||
import os
|
||||
import runs_on
|
||||
import pytest
|
||||
|
||||
# making sure we're not doing any fallback restore:
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_TIMEOUT"] = "1"
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_LIMIT"] = "1"
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
# Skipping the test on the ARM runners, as we're running into trouble with Mono and nuget.
|
||||
@pytest.mark.only_if(runs_on.linux or (runs_on.macos and runs_on.x86_64))
|
||||
def test(codeql, csharp):
|
||||
# making sure we're not doing any fallback restore:
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_TIMEOUT"] = "1"
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_LIMIT"] = "1"
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Skipping the test on the ARM runners, as we're running into trouble with Mono and nuget.
|
||||
@@ -1,3 +1,8 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
import pytest
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
# Skipping the test on the ARM runners, as we're running into trouble with Mono and nuget.
|
||||
@pytest.mark.only_if(runs_on.linux or (runs_on.macos and runs_on.x86_64))
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import os
|
||||
import runs_on
|
||||
|
||||
# os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK"] = "true" # Nuget feed check is enabled by default
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_TIMEOUT"] = "1" # 1ms, the GET request should fail with such short timeout
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_LIMIT"] = "1" # Limit the count of checks to 1
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_EXCLUDED"] = "https://abc.de:8000/packages/" # Exclude this feed from check
|
||||
|
||||
# Making sure the reachability test of `nuget.org` succeeds:
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_TIMEOUT"] = "1000"
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_LIMIT"] = "5"
|
||||
# The second feed is ignored in the fallback restore, because of network issues:
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_FALLBACK"] = "https://api.nuget.org/v3/index.json https://abc.def:8000/packages/"
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
# os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK"] = "true" # Nuget feed check is enabled by default
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_TIMEOUT"] = (
|
||||
"1" # 1ms, the GET request should fail with such short timeout
|
||||
)
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_LIMIT"] = (
|
||||
"1" # Limit the count of checks to 1
|
||||
)
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_EXCLUDED"] = (
|
||||
"https://abc.de:8000/packages/" # Exclude this feed from check
|
||||
)
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
check_diagnostics()
|
||||
# Making sure the reachability test of `nuget.org` succeeds:
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_TIMEOUT"] = "1000"
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_LIMIT"] = "5"
|
||||
# The second feed is ignored in the fallback restore, because of network issues:
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_FALLBACK"] = (
|
||||
"https://api.nuget.org/v3/index.json https://abc.def:8000/packages/"
|
||||
)
|
||||
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import os
|
||||
import runs_on
|
||||
|
||||
# os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK"] = "true" # Nuget feed check is enabled by default
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_TIMEOUT"] = "1" # 1ms, the GET request should fail with such short timeout
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_LIMIT"] = "1" # Limit the count of checks to 1
|
||||
|
||||
# Making sure the reachability test succeeds when doing a fallback restore:
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_TIMEOUT"] = "1000"
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_LIMIT"] = "5"
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
check_diagnostics()
|
||||
# os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK"] = "true" # Nuget feed check is enabled by default
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_TIMEOUT"] = (
|
||||
"1" # 1ms, the GET request should fail with such short timeout
|
||||
)
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_LIMIT"] = (
|
||||
"1" # Limit the count of checks to 1
|
||||
)
|
||||
|
||||
# Making sure the reachability test succeeds when doing a fallback restore:
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_TIMEOUT"] = "1000"
|
||||
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_NUGET_FEEDS_CHECK_FALLBACK_LIMIT"] = "5"
|
||||
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
Skipping the test on the ARM runners, as we're running into trouble with Mono and nuget.
|
||||
@@ -1,3 +1,8 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
import pytest
|
||||
|
||||
run_codeql_database_create([], source="proj", lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
# Skipping the test on the ARM runners, as we're running into trouble with Mono and nuget.
|
||||
@pytest.mark.only_if(runs_on.linux or (runs_on.macos and runs_on.x86_64))
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(source_root="proj", build_mode="none")
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import os
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create(["./build.sh"], lang="csharp")
|
||||
|
||||
check_diagnostics()
|
||||
@runs_on.posix
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(command="./build.sh")
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
dependencies:
|
||||
codeql/csharp-all: '*'
|
||||
codeql/csharp-queries: '*'
|
||||
warnOnImplicitThis: true
|
||||
@@ -1,5 +1,6 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully)
|
||||
check_diagnostics()
|
||||
|
||||
@runs_on.windows
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(_assert_failure=True)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from create_database_utils import *
|
||||
from diagnostics_test_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], db=None, lang="csharp", runFunction=runUnsuccessfully)
|
||||
check_diagnostics()
|
||||
|
||||
@runs_on.windows
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(_assert_failure=True)
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
from create_database_utils import *
|
||||
import runs_on
|
||||
|
||||
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none"])
|
||||
|
||||
@runs_on.windows
|
||||
def test(codeql, csharp):
|
||||
codeql.database.create(build_mode="none")
|
||||
|
||||
Reference in New Issue
Block a user