Skip to content

Commit 59922e5

Browse files
committed
Port C# tests to pytest.
1 parent e222b49 commit 59922e5

File tree

65 files changed

+313
-276
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+313
-276
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
from create_database_utils import *
2-
3-
run_codeql_database_create([], lang="csharp")
1+
def test(codeql, csharp):
2+
codeql.database.create()
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import subprocess
2-
from create_database_utils import *
3-
from diagnostics_test_utils import *
1+
import commands
42

5-
subprocess.check_call(["dotnet", "build", "test.sln", "/bl:test.binlog"])
6-
run_codeql_database_create([], lang="csharp", extra_args=["--build-mode=none", "-Obinlog=test.binlog"])
7-
check_diagnostics()
3+
4+
def test(codeql, csharp):
5+
commands.run(["dotnet", "build", "test.sln", "/bl:test.binlog"])
6+
codeql.database.create(build_mode="none", extractor_option="binlog=test.binlog")
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
from create_database_utils import *
2-
3-
run_codeql_database_create(['dotnet build'], lang="csharp")
1+
def test(codeql, csharp):
2+
codeql.database.create(command="dotnet build")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
| Program.cs |
22
| Views/Home/Index.cshtml |
3-
| _semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_Views_Home_Index_cshtml.g.cs |
3+
| _ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_test_test_Views_Home_Index_cshtml.g.cs |
44
| test-db/working/implicitUsings/GlobalUsings.g.cs |

csharp/ql/integration-tests/all-platforms/cshtml_standalone/Files.ql

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ import csharp
22

33
private string getPath(File f) {
44
result = f.getRelativePath() and
5-
not exists(
6-
result
7-
.indexOf("_semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_")
8-
)
5+
not exists(result.indexOf("_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_"))
96
or
107
exists(int index |
118
index =
129
f.getRelativePath()
13-
.indexOf("_semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_") and
10+
.indexOf("_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_") and
1411
result = f.getRelativePath().substring(index, f.getRelativePath().length())
1512
)
1613
}
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
import os
2-
from create_database_utils import *
3-
4-
run_codeql_database_create(lang="csharp", extra_args=["--build-mode=none"])
1+
def test(codeql, csharp):
2+
codeql.database.create(build_mode="none")
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
2-
from create_database_utils import *
32

4-
os.environ['CODEQL_EXTRACTOR_CSHARP_BUILDLESS_EXTRACT_WEB_VIEWS'] = 'false'
5-
run_codeql_database_create(lang="csharp", extra_args=["--build-mode=none"])
3+
4+
def test(codeql, csharp):
5+
os.environ["CODEQL_EXTRACTOR_CSHARP_BUILDLESS_EXTRACT_WEB_VIEWS"] = "false"
6+
codeql.database.create(build_mode="none")
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
import os
2-
from create_database_utils import *
3-
4-
run_codeql_database_create(lang="csharp", extra_args=["--build-mode=none"])
1+
def test(codeql, csharp):
2+
codeql.database.create(build_mode="none")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
| Program.cs |
22
| Views/Home/Index.cshtml |
3-
| _semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_net6_Views_Home_Index_cshtml.g.cs |
3+
| _ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_net6_test_test_Views_Home_Index_cshtml.g.cs |
44
| test-db/working/implicitUsings/GlobalUsings.g.cs |

csharp/ql/integration-tests/all-platforms/cshtml_standalone_net6/Files.ql

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@ import csharp
22

33
private string getPath(File f) {
44
result = f.getRelativePath() and
5-
not exists(
6-
result
7-
.indexOf("_semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_")
8-
)
5+
not exists(result.indexOf("_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_"))
96
or
107
exists(int index |
118
index =
129
f.getRelativePath()
13-
.indexOf("_semmle_code_target_codeql_csharp_integration_tests_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_") and
10+
.indexOf("_ql_csharp_ql_integration_tests_all_platforms_cshtml_standalone_") and
1411
result = f.getRelativePath().substring(index, f.getRelativePath().length())
1512
)
1613
}

0 commit comments

Comments
 (0)