JS: heuristically recognize x.spec.y and x.test.y as test files

This commit is contained in:
Esben Sparre Andreasen
2019-07-01 15:49:17 +02:00
parent 7cab308205
commit 062778bdd8
3 changed files with 10 additions and 2 deletions

View File

@@ -61,7 +61,14 @@ private predicate looksLikeExterns(TopLevel tl) {
predicate classify(File f, string category) {
isGenerated(f.getATopLevel()) and category = "generated"
or
exists(Test t | t.getFile() = f | category = "test")
(
exists(Test t | t.getFile() = f)
or
exists(string stemExt | stemExt = "test" or stemExt = "spec" |
f = getTestFile(any(File orig), stemExt)
)
) and
category = "test"
or
(f.getATopLevel().isExterns() or looksLikeExterns(f.getATopLevel())) and
category = "externs"

View File

@@ -44,7 +44,7 @@ class BDDTest extends Test, @callexpr {
* same directory as `f` which is named `<base>.<ext>`.
*/
bindingset[stemExt]
private File getTestFile(File f, string stemExt) {
File getTestFile(File f, string stemExt) {
result = f.getParentContainer().getFile(f.getStem() + "." + stemExt + "." + f.getExtension())
}

View File

@@ -7,6 +7,7 @@
| etherpad.html:0:0:0:0 | etherpad.html | generated |
| exported-data.js:0:0:0:0 | exported-data.js | generated |
| htmltidy.html:0:0:0:0 | htmltidy.html | generated |
| implementation.spec.js:0:0:0:0 | implementation.spec.js | test |
| implementation.test.js:0:0:0:0 | implementation.test.js | test |
| jison-lex.js:0:0:0:0 | jison-lex.js | generated |
| jison.js:0:0:0:0 | jison.js | generated |