improve performance of getTestFile by finding possible test files first

This commit is contained in:
Erik Krogh Kristensen
2022-03-01 11:18:22 +01:00
committed by Jean Helie
parent b6b93065ff
commit 531825d9a6

View File

@@ -39,12 +39,14 @@ class BDDTest extends Test, @call_expr {
}
/**
* Gets the test file for `f` with stem extension `stemExt`.
* Gets the test file for `f` with stem extension `stemExt`, where `stemExt` is "test" or "spec".
* That is, a file named file named `<base>.<stemExt>.<ext>` in the
* same directory as `f` which is named `<base>.<ext>`.
*/
bindingset[stemExt]
pragma[noinline]
File getTestFile(File f, string stemExt) {
stemExt = ["test", "spec"] and
result.getBaseName().regexpMatch(".*\\.(test|spec)\\..*") and
result = f.getParentContainer().getFile(f.getStem() + "." + stemExt + "." + f.getExtension())
}