Skip to content

Commit

Permalink
Create unit test that demonstrates the shadycss issue with ScanDeps
Browse files Browse the repository at this point in the history
This is to help communicate externally the issues we've run into importing
#3026

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=210119801
  • Loading branch information
blickly committed Aug 27, 2018
1 parent 0b6c6da commit 243bb66
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/com/google/javascript/jscomp/deps/DepsGeneratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,49 @@ public void testEs6ModuleDeclareNamespace() throws Exception {
assertEquals(expected, output);
}

// Unit test for an issue run into by https://github.com/google/closure-compiler/pull/3026
public void testEs6ModuleScanDeps() throws Exception {
// Simple ES6 modules
ImmutableList<SourceFile> srcs =
ImmutableList.of(
SourceFile.fromCode("/src/css-parse.js", "export class StyleNode {}"),
SourceFile.fromCode(
"/src/apply-shim-utils.js", "import {StyleNode} from './css-parse.js';"));

// Run them through a DepsGenerator that is set up the same way as our internal MakeJsDeps tool.
DepsGenerator depsGenerator =
new DepsGenerator(
ImmutableList.of(),
srcs,
DepsGenerator.InclusionStrategy.ALWAYS,
PathUtil.makeAbsolute("/base/javascript/closure"),
errorManager,
new ModuleLoader(
null,
ImmutableList.of("."),
ImmutableList.of(),
BrowserModuleResolver.FACTORY,
ModuleLoader.PathResolver.ABSOLUTE));

String output = depsGenerator.computeDependencyCalls();

// Make sure that there are no spurious errors.
assertNoWarnings();

String expected =
LINE_JOINER.join(
"goog.addDependency('../../../src/css-parse.js',"
+ " [],"
+ " [],"
+ " {'lang': 'es6', 'module': 'es6'});",
"goog.addDependency('../../../src/apply-shim-utils.js',"
+ " [],"
+ " ['../../../src/css-parse.js'],"
+ " {'lang': 'es6', 'module': 'es6'});",
"");
assertThat(output).isEqualTo(expected);
}

/**
* Ensures that deps files are handled correctly both when listed as deps and when listed as
* sources.
Expand Down

0 comments on commit 243bb66

Please sign in to comment.