test/com/google/javascript/jscomp/deps/DepsGeneratorTest.java
/** Ensures that DepsGenerator deduplicates dependencies from custom Closure Library branches. */
Ensures that DepsGenerator deduplicates dependencies from custom Closure Library branches.
Ensures that DepsGenerator deduplicates dependencies from custom Closure Library branches .
@Test
  public void testDuplicateProvidesIgnoredIfInClosureDirectory() throws Exception {
    SourceFile fauxClosureDeps =
        SourceFile.fromCode("dep1.js", "goog.addDependency('foo/a.js', ['a'], []);\n");
    SourceFile fauxClosureSrc =
        SourceFile.fromCode("path/to/closure/foo/a.js", "goog.provide('a');\n");
    SourceFile userSrc =
        SourceFile.fromCode("my/package/script.js", "goog.require('a');\n"
            + "goog.provide('my.package.script');\n");
    DepsGenerator worker =
        new DepsGenerator(
            ImmutableList.of(fauxClosureDeps),
            ImmutableList.of(fauxClosureSrc, userSrc),
            DepsGenerator.InclusionStrategy.ALWAYS,
            PathUtil.makeAbsolute("./path/to/closure"),
            errorManager,
            new ModuleLoader(
                null,
                ImmutableList.of("."),
                ImmutableList.of(),
                BrowserModuleResolver.FACTORY,
                ModuleLoader.PathResolver.ABSOLUTE));
    String output = worker.computeDependencyCalls();
    assertWithMessage("Output should have been created.").that(output).isNotEmpty();
    assertNoWarnings();
  }
@ Test public void testDuplicateProvidesIgnoredIfInClosureDirectory ( ) throws Exception { SourceFile fauxClosureDeps = SourceFile . fromCode ( "dep1.js" , "goog.addDependency('foo/a.js', ['a'], []);\n" ) ; SourceFile fauxClosureSrc = SourceFile . fromCode ( "path/to/closure/foo/a.js" , "goog.provide('a');\n" ) ; SourceFile userSrc = SourceFile . fromCode ( "my/package/script.js" , "goog.require('a');\n" + "goog.provide('my.package.script');\n" ) ; DepsGenerator worker = new DepsGenerator ( ImmutableList . of ( fauxClosureDeps ) , ImmutableList . of ( fauxClosureSrc , userSrc ) , DepsGenerator . InclusionStrategy . ALWAYS , PathUtil . makeAbsolute ( "./path/to/closure" ) , errorManager , new ModuleLoader ( null , ImmutableList . of ( "." ) , ImmutableList . of ( ) , BrowserModuleResolver . FACTORY , ModuleLoader . PathResolver . ABSOLUTE ) ) ; String output = worker . computeDependencyCalls ( ) ; assertWithMessage ( "Output should have been created." ) . that ( output ) . isNotEmpty ( ) ; assertNoWarnings ( ) ; }
Ensures that DepsGenerator deduplicates dependencies from custom Closure Library branches.
Ensures that DepsGenerator deduplicates dependencies from custom Closure Library branches .
// Create a stub Closure Library. // Create a source file that depends on the stub Closure Library.