Skip to content

Commit

Permalink
CheckRequiresForConstructors is now run in SINGLE_FILE mode for hot s…
Browse files Browse the repository at this point in the history
…wap passes.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=122871844
  • Loading branch information
joeltine authored and blickly committed May 20, 2016
1 parent 435758e commit c17287b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static enum Mode {
// Used during a normal compilation. The entire program + externs are available.
FULL_COMPILE
};
private final Mode mode;
private Mode mode;

private final Set<String> providedNames = new HashSet<>();
private final Map<String, Node> requires = new HashMap<>();
Expand Down Expand Up @@ -124,6 +124,9 @@ public void process(Node externs, Node root) {

@Override
public void hotSwapScript(Node scriptRoot, Node originalRoot) {
// TODO(joeltine): Remove this and properly handle hot swap passes. See
// b/28869281 for context.
mode = Mode.SINGLE_FILE;
NodeTraversal.traverseEs6(compiler, scriptRoot, this);
}

Expand Down
14 changes: 6 additions & 8 deletions test/com/google/javascript/jscomp/SimpleReplaceScriptTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,9 @@ public void testCheckRequires() {
String source1 = "var a = new ns.Bar();";
Result result = runReplaceScript(options, ImmutableList.of(source0,
source1), 1, 0, source1, 1, true).getResult();
assertFalse(result.success);

assertThat(result.errors).hasLength(1);
assertErrorType(result.errors[0], CheckRequiresForConstructors.MISSING_REQUIRE_WARNING, 1);
// TODO(joeltine): Change back to asserting an error when b/28869281
// is fixed.
assertTrue(result.success);
}

public void testCheckRequiresWithNewVar() {
Expand All @@ -302,10 +301,9 @@ public void testCheckRequiresWithNewVar() {
String modifiedSrc = src + "\n(function() { var a = new ns.Bar(); })();";
Result result = runReplaceScript(options,
ImmutableList.of(src), 0, 0, modifiedSrc, 0, false).getResult();
assertFalse(result.success);

assertThat(result.errors).hasLength(1);
assertErrorType(result.errors[0], CheckRequiresForConstructors.MISSING_REQUIRE_WARNING, 2);
// TODO(joeltine): Change back to asserting an error when b/28869281
// is fixed.
assertTrue(result.success);
}

public void testCheckProvides() {
Expand Down

0 comments on commit c17287b

Please sign in to comment.