Skip to content

Commit

Permalink
Make LOAD_WARNING an error.
Browse files Browse the repository at this point in the history
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169711659
  • Loading branch information
tbreisacher authored and blickly committed Sep 22, 2017
1 parent 62d3242 commit 2957eae
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/deps/ModuleLoader.java
Expand Up @@ -52,7 +52,7 @@ public final class ModuleLoader {
public static final String DEFAULT_FILENAME_PREFIX = "." + MODULE_SLASH;

public static final DiagnosticType LOAD_WARNING =
DiagnosticType.warning("JSC_JS_MODULE_LOAD_WARNING", "Failed to load module \"{0}\"");
DiagnosticType.error("JSC_JS_MODULE_LOAD_WARNING", "Failed to load module \"{0}\"");

public static final DiagnosticType INVALID_MODULE_PATH =
DiagnosticType.error(
Expand Down
20 changes: 10 additions & 10 deletions test/com/google/javascript/jscomp/CompilerTest.java
Expand Up @@ -17,8 +17,8 @@
package com.google.javascript.jscomp;

import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;

import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand Down Expand Up @@ -147,9 +147,9 @@ public void testCommonJSMissingRequire() throws Exception {
inputs, ImmutableList.of(ModuleIdentifier.forFile("/gin")));

ErrorManager manager = compiler.getErrorManager();
JSError[] warnings = manager.getWarnings();
assertThat(warnings).hasLength(1);
String error = warnings[0].toString();
JSError[] errors = manager.getErrors();
assertThat(errors).hasLength(1);
String error = errors[0].toString();
assertThat(error).contains("Failed to load module \"missing\" at /gin.js");
}

Expand Down Expand Up @@ -229,9 +229,9 @@ public void testResolveRelativeSourceMap() throws Exception {
File tempDir = Files.createTempDir();
String code = SOURCE_MAP_TEST_CODE + "\n//# sourceMappingURL=foo.js.map";
File jsFile = new File(tempDir, "foo.js");
Files.asCharSink(jsFile, Charsets.UTF_8).write(code);
Files.asCharSink(jsFile, UTF_8).write(code);
File sourceMapFile = new File(tempDir, "foo.js.map");
Files.asCharSink(sourceMapFile, Charsets.UTF_8).write(SOURCE_MAP);
Files.asCharSink(sourceMapFile, UTF_8).write(SOURCE_MAP);

CompilerInput input = new CompilerInput(SourceFile.fromFile(jsFile.getAbsolutePath()));
input.getAstRoot(compiler);
Expand All @@ -253,9 +253,9 @@ public void testResolveRelativeDirSourceMap() throws Exception {
relativedir.mkdir();
String code = SOURCE_MAP_TEST_CODE + "\n//# sourceMappingURL=relativedir/foo.js.map";
File jsFile = new File(tempDir, "foo.js");
Files.asCharSink(jsFile, Charsets.UTF_8).write(code);
Files.asCharSink(jsFile, UTF_8).write(code);
File sourceMapFile = new File(relativedir, "foo.js.map");
Files.asCharSink(sourceMapFile, Charsets.UTF_8).write(SOURCE_MAP);
Files.asCharSink(sourceMapFile, UTF_8).write(SOURCE_MAP);

CompilerInput input = new CompilerInput(SourceFile.fromFile(jsFile.getAbsolutePath()));
input.getAstRoot(compiler);
Expand All @@ -274,7 +274,7 @@ public void testMissingSourceMapFile() throws Exception {
File tempDir = Files.createTempDir();
String code = SOURCE_MAP_TEST_CODE + "\n//# sourceMappingURL=foo-does-not-exist.js.map";
File jsFile = new File(tempDir, "foo2.js");
Files.asCharSink(jsFile, Charsets.UTF_8).write(code);
Files.asCharSink(jsFile, UTF_8).write(code);

CompilerInput input = new CompilerInput(SourceFile.fromFile(jsFile.getAbsolutePath()));
input.getAstRoot(compiler);
Expand All @@ -297,7 +297,7 @@ public void testNoWarningMissingAbsoluteSourceMap() throws Exception {
File tempDir = Files.createTempDir();
String code = SOURCE_MAP_TEST_CODE + "\n//# sourceMappingURL=/some/missing/path/foo.js.map";
File jsFile = new File(tempDir, "foo.js");
Files.asCharSink(jsFile, Charsets.UTF_8).write(code);
Files.asCharSink(jsFile, UTF_8).write(code);

CompilerInput input = new CompilerInput(SourceFile.fromFile(jsFile.getAbsolutePath()));
input.getAstRoot(compiler);
Expand Down
Expand Up @@ -95,7 +95,7 @@ public void testImport() {
}

public void testImport_missing() {
ModulesTestUtils.testModulesWarning(this, "import name from './does_not_exist';\n use(name);",
ModulesTestUtils.testModulesError(this, "import name from './does_not_exist';\n use(name);",
ModuleLoader.LOAD_WARNING);
}

Expand Down

0 comments on commit 2957eae

Please sign in to comment.