Skip to content

Commit 8e8efed

Browse files
committed
Rust: adjust integration tests and expected output
1 parent 53b2e97 commit 8e8efed

14 files changed

+88
-9
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"pretty": "__REDACTED__"
3131
}
3232
},
33-
"numberOfFiles": 5,
33+
"numberOfFiles": 6,
3434
"numberOfManifests": 1
3535
},
3636
"severity": "note",

rust/ql/integration-tests/hello-project/steps.cargo.expected

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
| Cargo.toml:0:0:0:0 | LoadManifest(Cargo.toml) |
2+
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
3+
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
24
| file://:0:0:0:0 | CrateGraph |
35
| file://:0:0:0:0 | FindManifests |
46
| src/directory_module/mod.rs:0:0:0:0 | Extract(src/directory_module/mod.rs) |
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
import codeql.rust.elements.internal.ExtractorStep
22

3-
from ExtractorStep step
3+
private class Step instanceof ExtractorStep {
4+
string toString() {
5+
result = super.getAction() + "(" + this.getFilePath() + ")"
6+
or
7+
not super.hasFile() and result = super.getAction()
8+
}
9+
10+
private string getFilePath() {
11+
exists(File file | file = super.getFile() |
12+
exists(file.getRelativePath()) and result = file.getAbsolutePath()
13+
or
14+
not exists(file.getRelativePath()) and result = "/" + file.getBaseName()
15+
)
16+
}
17+
18+
predicate hasLocationInfo(
19+
string filepath, int startline, int startcolumn, int endline, int endcolumn
20+
) {
21+
super.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
22+
filepath = this.getFilePath()
23+
}
24+
}
25+
26+
from Step step
427
select step

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

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
2+
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
13
| file://:0:0:0:0 | CrateGraph |
24
| file://:0:0:0:0 | FindManifests |
35
| rust-project.json:0:0:0:0 | LoadManifest(rust-project.json) |

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| Inconsistencies - Path resolution | 0 |
1010
| Inconsistencies - SSA | 0 |
1111
| Inconsistencies - data flow | 0 |
12-
| Lines of code extracted | 6 |
12+
| Lines of code extracted | 23 |
1313
| Lines of user code extracted | 6 |
1414
| Macro calls - resolved | 2 |
1515
| Macro calls - total | 2 |

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"pretty": "__REDACTED__"
3131
}
3232
},
33-
"numberOfFiles": 4,
33+
"numberOfFiles": 5,
3434
"numberOfManifests": 1
3535
},
3636
"severity": "note",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"pretty": "__REDACTED__"
3131
}
3232
},
33-
"numberOfFiles": 4,
33+
"numberOfFiles": 5,
3434
"numberOfManifests": 1
3535
},
3636
"severity": "note",

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

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
| exe/src/main.rs:0:0:0:0 | Extract(exe/src/main.rs) |
66
| exe/src/main.rs:0:0:0:0 | LoadSource(exe/src/main.rs) |
77
| exe/src/main.rs:0:0:0:0 | Parse(exe/src/main.rs) |
8+
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
9+
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
810
| file://:0:0:0:0 | CrateGraph |
911
| file://:0:0:0:0 | FindManifests |
1012
| lib/src/a_module/mod.rs:0:0:0:0 | Extract(lib/src/a_module/mod.rs) |
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
import codeql.rust.elements.internal.ExtractorStep
22

3-
from ExtractorStep step
3+
private class Step instanceof ExtractorStep {
4+
string toString() {
5+
result = super.getAction() + "(" + this.getFilePath() + ")"
6+
or
7+
not super.hasFile() and result = super.getAction()
8+
}
9+
10+
private string getFilePath() {
11+
exists(File file | file = super.getFile() |
12+
exists(file.getRelativePath()) and result = file.getAbsolutePath()
13+
or
14+
not exists(file.getRelativePath()) and result = "/" + file.getBaseName()
15+
)
16+
}
17+
18+
predicate hasLocationInfo(
19+
string filepath, int startline, int startcolumn, int endline, int endcolumn
20+
) {
21+
super.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
22+
filepath = this.getFilePath()
23+
}
24+
}
25+
26+
from Step step
427
select step

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

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
| exe/src/main.rs:0:0:0:0 | Extract(exe/src/main.rs) |
55
| exe/src/main.rs:0:0:0:0 | LoadSource(exe/src/main.rs) |
66
| exe/src/main.rs:0:0:0:0 | Parse(exe/src/main.rs) |
7+
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
8+
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
79
| file://:0:0:0:0 | CrateGraph |
810
| file://:0:0:0:0 | FindManifests |
911
| lib/src/a_module/mod.rs:0:0:0:0 | Extract(lib/src/a_module/mod.rs) |

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| Inconsistencies - Path resolution | 0 |
1010
| Inconsistencies - SSA | 0 |
1111
| Inconsistencies - data flow | 0 |
12-
| Lines of code extracted | 9 |
12+
| Lines of code extracted | 26 |
1313
| Lines of user code extracted | 9 |
1414
| Macro calls - resolved | 2 |
1515
| Macro calls - total | 2 |

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| Inconsistencies - Path resolution | 0 |
1010
| Inconsistencies - SSA | 0 |
1111
| Inconsistencies - data flow | 0 |
12-
| Lines of code extracted | 9 |
12+
| Lines of code extracted | 26 |
1313
| Lines of user code extracted | 9 |
1414
| Macro calls - resolved | 2 |
1515
| Macro calls - total | 2 |

rust/ql/integration-tests/workspace-with-glob/steps.expected

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
| Cargo.toml:0:0:0:0 | LoadManifest(Cargo.toml) |
22
| exe/src/main.rs:0:0:0:0 | Extract(exe/src/main.rs) |
33
| exe/src/main.rs:0:0:0:0 | Parse(exe/src/main.rs) |
4+
| file:///types.rs:0:0:0:0 | Extract(/types.rs) |
5+
| file:///types.rs:0:0:0:0 | Parse(/types.rs) |
46
| file://:0:0:0:0 | CrateGraph |
57
| file://:0:0:0:0 | FindManifests |
68
| lib/src/lib.rs:0:0:0:0 | Extract(lib/src/lib.rs) |
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,27 @@
11
import codeql.rust.elements.internal.ExtractorStep
22

3-
from ExtractorStep step
3+
private class Step instanceof ExtractorStep {
4+
string toString() {
5+
result = super.getAction() + "(" + this.getFilePath() + ")"
6+
or
7+
not super.hasFile() and result = super.getAction()
8+
}
9+
10+
private string getFilePath() {
11+
exists(File file | file = super.getFile() |
12+
exists(file.getRelativePath()) and result = file.getAbsolutePath()
13+
or
14+
not exists(file.getRelativePath()) and result = "/" + file.getBaseName()
15+
)
16+
}
17+
18+
predicate hasLocationInfo(
19+
string filepath, int startline, int startcolumn, int endline, int endcolumn
20+
) {
21+
super.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
22+
filepath = this.getFilePath()
23+
}
24+
}
25+
26+
from Step step
427
select step

0 commit comments

Comments
 (0)