Skip to content

Commit 5251dc2

Browse files
author
Paolo Tranquilli
committed
Rust: use check_diagnostics improvements
1 parent 27738ea commit 5251dc2

File tree

4 files changed

+246
-26
lines changed

4 files changed

+246
-26
lines changed

rust/ql/integration-tests/conftest.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ def manifests(cwd):
1717
@pytest.fixture
1818
def rust_check_diagnostics(check_diagnostics):
1919
check_diagnostics.replacements += [
20-
(r'"ms"\s*:\s*[0-9]+', '"ms": "__REDACTED__"'),
21-
(r'"pretty"\s*:\s*"[^"]*"', '"pretty": "__REDACTED__"'),
20+
("Cargo.toml|rust-project.json", "<manifest-file>"),
2221
]
23-
check_diagnostics.skip += [
24-
"attributes.steps", # the order of the steps is not stable
22+
check_diagnostics.redact += [
23+
"attributes.summary.durations.*.ms",
24+
"attributes.summary.durations.*.pretty",
25+
"attributes.steps.ms",
2526
]
27+
check_diagnostics.sort = True # the order of the steps is not stable
2628
return check_diagnostics

rust/ql/integration-tests/hello-project/diagnostics.expected

Lines changed: 101 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,107 @@
11
{
22
"attributes": {
3-
"summary": {
4-
"numberOfFiles": 4,
5-
"numberOfManifests": 1,
6-
"totalDuration": {
7-
"ms": "__REDACTED__",
8-
"pretty": "__REDACTED__"
9-
},
10-
"totalExtractDuration": {
11-
"ms": "__REDACTED__",
12-
"pretty": "__REDACTED__"
13-
},
14-
"totalFetchFileDuration": {
15-
"ms": "__REDACTED__",
16-
"pretty": "__REDACTED__"
17-
},
18-
"totalLoadDuration": {
19-
"ms": "__REDACTED__",
20-
"pretty": "__REDACTED__"
21-
},
22-
"totalParseDuration": {
23-
"ms": "__REDACTED__",
24-
"pretty": "__REDACTED__"
3+
"steps": [
4+
{
5+
"action": "extract",
6+
"file": "<test-root-directory>/src/directory_module/mod.rs",
7+
"ms": "__REDACTED__"
8+
},
9+
{
10+
"action": "extract",
11+
"file": "<test-root-directory>/src/directory_module/nested_module.rs",
12+
"ms": "__REDACTED__"
13+
},
14+
{
15+
"action": "extract",
16+
"file": "<test-root-directory>/src/directory_module/not_loaded.rs",
17+
"ms": "__REDACTED__"
18+
},
19+
{
20+
"action": "extract",
21+
"file": "<test-root-directory>/src/file_module.rs",
22+
"ms": "__REDACTED__"
23+
},
24+
{
25+
"action": "extract",
26+
"file": "<test-root-directory>/src/main.rs",
27+
"ms": "__REDACTED__"
28+
},
29+
{
30+
"action": "loadManifest",
31+
"file": "<test-root-directory>/<manifest-file>",
32+
"ms": "__REDACTED__"
33+
},
34+
{
35+
"action": "loadSource",
36+
"file": "<test-root-directory>/src/directory_module/mod.rs",
37+
"ms": "__REDACTED__"
38+
},
39+
{
40+
"action": "loadSource",
41+
"file": "<test-root-directory>/src/directory_module/nested_module.rs",
42+
"ms": "__REDACTED__"
43+
},
44+
{
45+
"action": "loadSource",
46+
"file": "<test-root-directory>/src/file_module.rs",
47+
"ms": "__REDACTED__"
48+
},
49+
{
50+
"action": "loadSource",
51+
"file": "<test-root-directory>/src/main.rs",
52+
"ms": "__REDACTED__"
53+
},
54+
{
55+
"action": "parse",
56+
"file": "<test-root-directory>/src/directory_module/mod.rs",
57+
"ms": "__REDACTED__"
58+
},
59+
{
60+
"action": "parse",
61+
"file": "<test-root-directory>/src/directory_module/nested_module.rs",
62+
"ms": "__REDACTED__"
63+
},
64+
{
65+
"action": "parse",
66+
"file": "<test-root-directory>/src/directory_module/not_loaded.rs",
67+
"ms": "__REDACTED__"
68+
},
69+
{
70+
"action": "parse",
71+
"file": "<test-root-directory>/src/file_module.rs",
72+
"ms": "__REDACTED__"
73+
},
74+
{
75+
"action": "parse",
76+
"file": "<test-root-directory>/src/main.rs",
77+
"ms": "__REDACTED__"
2578
}
79+
],
80+
"summary": {
81+
"durations": {
82+
"extract": {
83+
"ms": "__REDACTED__",
84+
"pretty": "__REDACTED__"
85+
},
86+
"loadManifest": {
87+
"ms": "__REDACTED__",
88+
"pretty": "__REDACTED__"
89+
},
90+
"loadSource": {
91+
"ms": "__REDACTED__",
92+
"pretty": "__REDACTED__"
93+
},
94+
"parse": {
95+
"ms": "__REDACTED__",
96+
"pretty": "__REDACTED__"
97+
},
98+
"total": {
99+
"ms": "__REDACTED__",
100+
"pretty": "__REDACTED__"
101+
}
102+
},
103+
"numberOfFiles": 5,
104+
"numberOfManifests": 1
26105
}
27106
},
28107
"severity": "note",

rust/ql/integration-tests/hello-workspace/diagnostics.cargo.expected

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,77 @@
11
{
22
"attributes": {
3+
"steps": [
4+
{
5+
"action": "extract",
6+
"file": "<test-root-directory>/exe/src/a_module.rs",
7+
"ms": "__REDACTED__"
8+
},
9+
{
10+
"action": "extract",
11+
"file": "<test-root-directory>/exe/src/main.rs",
12+
"ms": "__REDACTED__"
13+
},
14+
{
15+
"action": "extract",
16+
"file": "<test-root-directory>/lib/src/a_module/mod.rs",
17+
"ms": "__REDACTED__"
18+
},
19+
{
20+
"action": "extract",
21+
"file": "<test-root-directory>/lib/src/lib.rs",
22+
"ms": "__REDACTED__"
23+
},
24+
{
25+
"action": "loadManifest",
26+
"file": "<test-root-directory>/exe/<manifest-file>",
27+
"ms": "__REDACTED__"
28+
},
29+
{
30+
"action": "loadManifest",
31+
"file": "<test-root-directory>/lib/<manifest-file>",
32+
"ms": "__REDACTED__"
33+
},
34+
{
35+
"action": "loadSource",
36+
"file": "<test-root-directory>/exe/src/a_module.rs",
37+
"ms": "__REDACTED__"
38+
},
39+
{
40+
"action": "loadSource",
41+
"file": "<test-root-directory>/exe/src/main.rs",
42+
"ms": "__REDACTED__"
43+
},
44+
{
45+
"action": "loadSource",
46+
"file": "<test-root-directory>/lib/src/a_module/mod.rs",
47+
"ms": "__REDACTED__"
48+
},
49+
{
50+
"action": "loadSource",
51+
"file": "<test-root-directory>/lib/src/lib.rs",
52+
"ms": "__REDACTED__"
53+
},
54+
{
55+
"action": "parse",
56+
"file": "<test-root-directory>/exe/src/a_module.rs",
57+
"ms": "__REDACTED__"
58+
},
59+
{
60+
"action": "parse",
61+
"file": "<test-root-directory>/exe/src/main.rs",
62+
"ms": "__REDACTED__"
63+
},
64+
{
65+
"action": "parse",
66+
"file": "<test-root-directory>/lib/src/a_module/mod.rs",
67+
"ms": "__REDACTED__"
68+
},
69+
{
70+
"action": "parse",
71+
"file": "<test-root-directory>/lib/src/lib.rs",
72+
"ms": "__REDACTED__"
73+
}
74+
],
375
"summary": {
476
"durations": {
577
"extract": {

rust/ql/integration-tests/hello-workspace/diagnostics.rust-project.expected

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,72 @@
11
{
22
"attributes": {
3+
"steps": [
4+
{
5+
"action": "extract",
6+
"file": "<test-root-directory>/exe/src/a_module.rs",
7+
"ms": "__REDACTED__"
8+
},
9+
{
10+
"action": "extract",
11+
"file": "<test-root-directory>/exe/src/main.rs",
12+
"ms": "__REDACTED__"
13+
},
14+
{
15+
"action": "extract",
16+
"file": "<test-root-directory>/lib/src/a_module/mod.rs",
17+
"ms": "__REDACTED__"
18+
},
19+
{
20+
"action": "extract",
21+
"file": "<test-root-directory>/lib/src/lib.rs",
22+
"ms": "__REDACTED__"
23+
},
24+
{
25+
"action": "loadManifest",
26+
"file": "<test-root-directory>/<manifest-file>",
27+
"ms": "__REDACTED__"
28+
},
29+
{
30+
"action": "loadSource",
31+
"file": "<test-root-directory>/exe/src/a_module.rs",
32+
"ms": "__REDACTED__"
33+
},
34+
{
35+
"action": "loadSource",
36+
"file": "<test-root-directory>/exe/src/main.rs",
37+
"ms": "__REDACTED__"
38+
},
39+
{
40+
"action": "loadSource",
41+
"file": "<test-root-directory>/lib/src/a_module/mod.rs",
42+
"ms": "__REDACTED__"
43+
},
44+
{
45+
"action": "loadSource",
46+
"file": "<test-root-directory>/lib/src/lib.rs",
47+
"ms": "__REDACTED__"
48+
},
49+
{
50+
"action": "parse",
51+
"file": "<test-root-directory>/exe/src/a_module.rs",
52+
"ms": "__REDACTED__"
53+
},
54+
{
55+
"action": "parse",
56+
"file": "<test-root-directory>/exe/src/main.rs",
57+
"ms": "__REDACTED__"
58+
},
59+
{
60+
"action": "parse",
61+
"file": "<test-root-directory>/lib/src/a_module/mod.rs",
62+
"ms": "__REDACTED__"
63+
},
64+
{
65+
"action": "parse",
66+
"file": "<test-root-directory>/lib/src/lib.rs",
67+
"ms": "__REDACTED__"
68+
}
69+
],
370
"summary": {
471
"durations": {
572
"extract": {

0 commit comments

Comments
 (0)