Skip to content

Commit bdd07de

Browse files
committed
improve performance of getTestFile by finding possible test files first
1 parent 5ce6b84 commit bdd07de

File tree

1 file changed

+4
-2
lines changed
  • javascript/ql/lib/semmle/javascript/frameworks

1 file changed

+4
-2
lines changed

javascript/ql/lib/semmle/javascript/frameworks/Testing.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ class BDDTest extends Test, @call_expr {
3939
}
4040

4141
/**
42-
* Gets the test file for `f` with stem extension `stemExt`.
42+
* Gets the test file for `f` with stem extension `stemExt`, where `stemExt` is "test" or "spec".
4343
* That is, a file named file named `<base>.<stemExt>.<ext>` in the
4444
* same directory as `f` which is named `<base>.<ext>`.
4545
*/
46-
bindingset[stemExt]
46+
pragma[noinline]
4747
File getTestFile(File f, string stemExt) {
48+
stemExt = ["test", "spec"] and
49+
result.getBaseName().regexpMatch(".*\\.(test|spec)\\..*") and
4850
result = f.getParentContainer().getFile(f.getStem() + "." + stemExt + "." + f.getExtension())
4951
}
5052

0 commit comments

Comments
 (0)