Skip to content

Commit 0d174f2

Browse files
author
Sauyon Lee
committed
Only include support methods and imports from working test cases
1 parent 2132ee5 commit 0d174f2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

java/ql/src/utils/GenerateFlowTestCase.qll

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,17 @@ query string noTestCaseGenerated() {
5757
not exists(any(TestCase tc).getATestSnippetForRow(result))
5858
}
5959

60+
/**
61+
* Gets a valid test case, i.e. one that has a test snippet.
62+
*/
63+
TestCase getAValidTestCase() { exists(result.getATestSnippetForRow(_)) }
64+
6065
/**
6166
* Returns an import statement to include in the test case header.
6267
*/
6368
string getAnImportStatement() {
6469
exists(RefType t |
65-
t = any(TestCase tc).getADesiredImport() and
70+
t = getAValidTestCase().getADesiredImport() and
6671
isImportable(t) and
6772
t.getPackage().getName() != "java.lang"
6873
|
@@ -76,7 +81,7 @@ string getAnImportStatement() {
7681
SupportMethod getASupportMethod() {
7782
result instanceof SourceMethod or
7883
result instanceof SinkMethod or
79-
result = any(TestCase tc).getASupportMethod()
84+
result = getAValidTestCase().getASupportMethod()
8085
}
8186

8287
/**

0 commit comments

Comments
 (0)