Skip to content

Commit bac3357

Browse files
authored
Merge pull request #22592 from hvitved/inline-expectations-relative-restriction
Inline expectations: Ignore results in files outside the source dir
2 parents ee551a8 + 7c8d3af commit bac3357

27 files changed

Lines changed: 164 additions & 163 deletions

File tree

actions/ql/test/utils/ActionsInlineExpectationsTestQuery.ql

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ import T::TestPostProcessing
1010
private module Impl implements T::InlineExpectationsTestSig {
1111
class Location = Locations::Location;
1212

13-
class ExpectationComment extends Yaml::YamlComment {
14-
string getContents() { result = this.getText() }
15-
}
16-
}
17-
18-
private module Input implements T::TestPostProcessing::InputSig<Impl> {
1913
string getRelativeUrl(Locations::Location location) {
2014
exists(int startLine, int startColumn, int endLine, int endColumn |
2115
location.hasLocationInfo(_, startLine, startColumn, endLine, endColumn)
@@ -25,6 +19,10 @@ private module Input implements T::TestPostProcessing::InputSig<Impl> {
2519
":" + endColumn
2620
)
2721
}
22+
23+
class ExpectationComment extends Yaml::YamlComment {
24+
string getContents() { result = this.getText() }
25+
}
2826
}
2927

30-
import T::TestPostProcessing::Make<Impl, Input>
28+
import T::TestPostProcessing::Make<Impl>

cpp/ql/lib/utils/test/InlineExpectationsTestQuery.ql

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,4 @@ private import cpp
66
private import codeql.util.test.InlineExpectationsTest as T
77
private import internal.InlineExpectationsTestImpl
88
import T::TestPostProcessing
9-
import T::TestPostProcessing::Make<Impl, Input>
10-
11-
private module Input implements T::TestPostProcessing::InputSig<Impl> {
12-
string getRelativeUrl(Location location) {
13-
exists(File f, int startline, int startcolumn, int endline, int endcolumn |
14-
location.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
15-
f = location.getFile()
16-
|
17-
result =
18-
f.getRelativePath() + ":" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
19-
)
20-
}
21-
}
9+
import T::TestPostProcessing::Make<Impl>

cpp/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,14 @@ module Impl implements InlineExpectationsTestSig {
2525
}
2626

2727
class Location = C::Location;
28+
29+
string getRelativeUrl(Location location) {
30+
exists(C::File f, int startline, int startcolumn, int endline, int endcolumn |
31+
location.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
32+
f = location.getFile()
33+
|
34+
result =
35+
f.getRelativePath() + ":" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
36+
)
37+
}
2838
}

cpp/ql/test/include/iterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace std {
6565
};
6666

6767
template<class Container>
68-
constexpr back_insert_iterator<Container> back_inserter(Container& x) { // $ ir-def=*x
68+
constexpr back_insert_iterator<Container> back_inserter(Container& x) {
6969
return back_insert_iterator<Container>(x);
7070
}
7171

@@ -89,7 +89,7 @@ namespace std {
8989
constexpr front_insert_iterator operator++(int);
9090
};
9191
template<class Container>
92-
constexpr front_insert_iterator<Container> front_inserter(Container& x) { // $ ir-def=*x
92+
constexpr front_insert_iterator<Container> front_inserter(Container& x) {
9393
return front_insert_iterator<Container>(x);
9494
}
9595
}

csharp/ql/lib/utils/test/InlineExpectationsTestQuery.ql

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,4 @@ private import csharp
66
private import codeql.util.test.InlineExpectationsTest as T
77
private import internal.InlineExpectationsTestImpl
88
import T::TestPostProcessing
9-
import T::TestPostProcessing::Make<Impl, Input>
10-
11-
private module Input implements T::TestPostProcessing::InputSig<Impl> {
12-
string getRelativeUrl(Location location) {
13-
exists(File f, int startline, int startcolumn, int endline, int endcolumn |
14-
location.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
15-
f = location.getFile()
16-
|
17-
result =
18-
f.getRelativePath() + ":" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
19-
)
20-
}
21-
}
9+
import T::TestPostProcessing::Make<Impl>

csharp/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,14 @@ module Impl implements InlineExpectationsTestSig {
4949
}
5050

5151
class Location = CS::Location;
52+
53+
string getRelativeUrl(Location location) {
54+
exists(CS::File f, int startline, int startcolumn, int endline, int endcolumn |
55+
location.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
56+
f = location.getFile()
57+
|
58+
result =
59+
f.getRelativePath() + ":" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
60+
)
61+
}
5262
}

go/ql/lib/utils/test/InlineExpectationsTestQuery.ql

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,4 @@ private import go
66
private import codeql.util.test.InlineExpectationsTest as T
77
private import internal.InlineExpectationsTestImpl
88
import T::TestPostProcessing
9-
import T::TestPostProcessing::Make<Impl, Input>
10-
11-
private module Input implements T::TestPostProcessing::InputSig<Impl> {
12-
string getRelativeUrl(Location location) {
13-
exists(File f, int startline, int startcolumn, int endline, int endcolumn |
14-
location.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
15-
f = location.getFile()
16-
|
17-
result =
18-
f.getRelativePath() + ":" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
19-
)
20-
}
21-
}
9+
import T::TestPostProcessing::Make<Impl>

go/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,14 @@ module Impl implements InlineExpectationsTestSig {
2020
}
2121

2222
class Location = G::Location;
23+
24+
string getRelativeUrl(Location location) {
25+
exists(G::File f, int startline, int startcolumn, int endline, int endcolumn |
26+
location.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
27+
f = location.getFile()
28+
|
29+
result =
30+
f.getRelativePath() + ":" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
31+
)
32+
}
2333
}

java/ql/lib/utils/test/InlineExpectationsTestQuery.ql

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,4 @@ private import java
66
private import codeql.util.test.InlineExpectationsTest as T
77
private import internal.InlineExpectationsTestImpl
88
import T::TestPostProcessing
9-
import T::TestPostProcessing::Make<Impl, Input>
10-
11-
private module Input implements T::TestPostProcessing::InputSig<Impl> {
12-
string getRelativeUrl(Location location) {
13-
exists(File f, int startline, int startcolumn, int endline, int endcolumn |
14-
location.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
15-
f = location.getFile()
16-
|
17-
result =
18-
f.getRelativePath() + ":" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
19-
)
20-
}
21-
}
9+
import T::TestPostProcessing::Make<Impl>

java/ql/lib/utils/test/internal/InlineExpectationsTestImpl.qll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,14 @@ module Impl implements InlineExpectationsTestSig {
3535
}
3636

3737
class Location = J::Location;
38+
39+
string getRelativeUrl(Location location) {
40+
exists(J::File f, int startline, int startcolumn, int endline, int endcolumn |
41+
location.hasLocationInfo(_, startline, startcolumn, endline, endcolumn) and
42+
f = location.getFile()
43+
|
44+
result =
45+
f.getRelativePath() + ":" + startline + ":" + startcolumn + ":" + endline + ":" + endcolumn
46+
)
47+
}
3848
}

0 commit comments

Comments
 (0)