diff --git a/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java b/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java index d7f8b0a8d28..266685e0abf 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java +++ b/javascript/extractor/src/com/semmle/js/extractor/AutoBuild.java @@ -434,19 +434,27 @@ public class AutoBuild { return true; } + /** + * Returns whether the autobuilder has seen code. + * This is overridden in tests. + */ + protected boolean hasSeenCode() { + return seenCode; + } + /** Perform extraction. */ public int run() throws IOException { startThreadPool(); try { extractSource(); extractXml(); - if (seenCode) { // don't bother with the externs if no code was seen + if (hasSeenCode()) { // don't bother with the externs if no code was seen extractExterns(); } } finally { shutdownThreadPool(); } - if (!seenCode) { + if (!hasSeenCode()) { if (seenFiles) { warn("Only found JavaScript or TypeScript files that were empty or contained syntax errors."); } else { diff --git a/javascript/extractor/src/com/semmle/js/extractor/test/AutoBuildTests.java b/javascript/extractor/src/com/semmle/js/extractor/test/AutoBuildTests.java index d472353067e..7c60a05d33f 100644 --- a/javascript/extractor/src/com/semmle/js/extractor/test/AutoBuildTests.java +++ b/javascript/extractor/src/com/semmle/js/extractor/test/AutoBuildTests.java @@ -119,6 +119,11 @@ public class AutoBuildTests { return CompletableFuture.completedFuture(null); } + @Override + protected boolean hasSeenCode() { + return true; + } + @Override public void verifyTypeScriptInstallation(ExtractorState state) {}