Package com.google.gwt.dev.util

Examples of com.google.gwt.dev.util.UnitTestTreeLogger


    UnitTestTreeLogger.Builder loggerBuilder = new UnitTestTreeLogger.Builder();
    loggerBuilder.setLowestLogLevel(TreeLogger.INFO);
    for (String expectedErrorMessage : expectedErrorMessages) {
      loggerBuilder.expectError(expectedErrorMessage, null);
    }
    UnitTestTreeLogger testLogger = loggerBuilder.createLogger();

    IncrementalBuilder incrementalBuilder =
        createIncrementalBuilder(rootModuleName, createGwtClassPathResourceLoader());
    incrementalBuilder.clean();

    boolean actualBuildSuccess = incrementalBuilder.build(testLogger).isSuccess();

    assertEquals(expectedBuildSuccess, actualBuildSuccess);
    testLogger.assertLogEntriesContainExpected();
  }
View Full Code Here


        "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleBottom"), null);
    loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
        "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleMid"), null);
    loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
        "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleTop"), null);
    UnitTestTreeLogger testLogger = loggerBuilder.createLogger();

    // Prepare the compiler.
    ResourceLoader resourceLoader = createGwtClassPathResourceLoaderWithMocks(
        "com/google/gwt/dev/testdata/incrementalbuildsystem/Foo.java");
    IncrementalBuilder incrementalBuilder = createIncrementalBuilder(
        "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleTop", resourceLoader);
    incrementalBuilder.clean();

    // Compile.
    boolean actualBuildSuccess = incrementalBuilder.build(testLogger).isSuccess();

    // Assert compile succeeded and was a full compile with no caching.
    assertEquals(true, actualBuildSuccess);
    testLogger.assertLogEntriesContainExpected();

    // Setup logging expectations for a fully cached compile.
    loggerBuilder = new UnitTestTreeLogger.Builder();
    loggerBuilder.setLowestLogLevel(TreeLogger.INFO);
    loggerBuilder.expectInfo(IncrementalBuilder.NO_FILES_HAVE_CHANGED, null);
    testLogger = loggerBuilder.createLogger();

    // Recompile without changes.
    actualBuildSuccess = incrementalBuilder.rebuild(testLogger).isSuccess();

    // Assert compile succeeded and was fully cached.
    assertEquals(true, actualBuildSuccess);
    testLogger.assertLogEntriesContainExpected();

    // Change modification date of the Foo.java seen by SimpleMid.gwt.xml
    File fooFile = new File(resourceLoader.getResource(
        "com/google/gwt/dev/testdata/incrementalbuildsystem/Foo.java").getPath());
    fooFile.setLastModified(System.currentTimeMillis() + 60 * 1000);

    // Setup logging expectations for partially cached recompile.
    loggerBuilder = new UnitTestTreeLogger.Builder();
    loggerBuilder.setLowestLogLevel(TreeLogger.SPAM);
    loggerBuilder.expectSpam(
        BuildTarget.formatReusingCachedLibraryMessage("com.google.gwt.core.Core"), null);
    loggerBuilder.expectSpam(BuildTarget.formatReusingCachedLibraryMessage(
        "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleBottom"), null);
    loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
        "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleMid"), null);
    loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
        "com.google.gwt.dev.testdata.incrementalbuildsystem.SimpleTop"), null);
    testLogger = loggerBuilder.createLogger();

    // Recompile with changes.
    actualBuildSuccess = incrementalBuilder.rebuild(testLogger).isSuccess();

    // Assert compile succeeded and was partially cached.
    assertEquals(true, actualBuildSuccess);
    testLogger.assertLogEntriesContainExpected();
  }
View Full Code Here

    loggerBuilder.setLowestLogLevel(TreeLogger.INFO);
    loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
        "com.google.gwt.dev.testdata.incrementalbuildsystem.MultipleFailLeft"), null);
    loggerBuilder.expectInfo(BuildTarget.formatCompilingModuleMessage(
        "com.google.gwt.dev.testdata.incrementalbuildsystem.MultipleFailRight"), null);
    UnitTestTreeLogger testLogger = loggerBuilder.createLogger();

    IncrementalBuilder incrementalBuilder = createIncrementalBuilder(
        "com.google.gwt.dev.testdata.incrementalbuildsystem.MultipleFailTop",
        createGwtClassPathResourceLoader());
    incrementalBuilder.clean();

    boolean buildSucceeded = incrementalBuilder.build(testLogger).isSuccess();
    assertFalse(buildSucceeded);
    testLogger.assertLogEntriesContainExpected();
  }
View Full Code Here

        null);
    loggerBuilder.expectError(Pattern.compile("Errors in '.*EntryPointCompileFails\\.java'"), null);
    loggerBuilder.expectError("Line 24: ImmediateCompileFails cannot be resolved to a type", null);
    loggerBuilder.expectError(Pattern.compile("Errors in '.*ImmediateCompileFails\\.java'"), null);
    loggerBuilder.expectError("Line 20: List cannot be resolved to a type", null);
    UnitTestTreeLogger testLogger = loggerBuilder.createLogger();

    IncrementalBuilder incrementalBuilder = createIncrementalBuilder(
        "com.google.gwt.dev.testdata.incrementalbuildsystem.CrossModuleCompileFails",
        createGwtClassPathResourceLoader());
    incrementalBuilder.clean();

    boolean buildSucceeded = incrementalBuilder.build(testLogger).isSuccess();
    assertFalse(buildSucceeded);
    testLogger.assertLogEntriesContainExpected();
  }
View Full Code Here

        null);
    loggerBuilder.expectError(Pattern.compile("Errors in '.*EntryPointCompileFails\\.java'"), null);
    loggerBuilder.expectError(causeTypeName + " cannot be resolved to a type", null);
    loggerBuilder.expectError(Pattern.compile("Errors in '.*ImmediateCompileFails\\.java'"), null);
    loggerBuilder.expectError("Line 20: List cannot be resolved to a type", null);
    UnitTestTreeLogger testLogger = loggerBuilder.createLogger();

    IncrementalBuilder incrementalBuilder = createIncrementalBuilder(
        "com.google.gwt.dev.testdata.incrementalbuildsystem.SameModuleCompileFails",
        createGwtClassPathResourceLoader());
    incrementalBuilder.clean();

    boolean buildSucceeded = incrementalBuilder.build(testLogger).isSuccess();
    assertFalse(buildSucceeded);
    testLogger.assertLogEntriesContainExpected();
  }
View Full Code Here

      builder.expectError("Errors in \'/mock/Buggy.java\'", null);
      for (String e : expectedErrors) {
        builder.expectError(e, null);
      }
    }
    UnitTestTreeLogger logger = builder.createLogger();
    StaticJavaResource buggyResource = new StaticJavaResource("Buggy",
        buggyCode);
    TypeOracleTestingUtils.buildStandardTypeOracleWith(logger,
        Collections.<Resource> emptySet(),
        CompilationStateTestBase.getGeneratedUnits(buggyResource));
    logger.assertCorrectLogEntries();
  }
View Full Code Here

    testLoggerBuilder = new UnitTestTreeLogger.Builder();
    testLoggerBuilder.setLowestLogLevel(TreeLogger.ERROR);
  }

  private void testSnippet(String codeSnippet) {
    UnitTestTreeLogger testLogger = testLoggerBuilder.createLogger();
    logger = testLogger;

    try {
      JProgram program = compileSnippet("void", codeSnippet);
      ReplaceRunAsyncs.exec(logger, program);
      fail("Expected a compile error");
    } catch (UnableToCompleteException e) {
      // expected
    }

    testLogger.assertCorrectLogEntries();
  }
View Full Code Here

        + "'FromModule1' has no dependency (neither direct nor transitive) on "
        + "'ToModule1|ToModule2|ToModule3'.", null);
    builder.expectWarn("Type 'FromType' wants to reference type 'ToType' but can't because module "
        + "'FromModule3' has no dependency (neither direct nor transitive) on "
        + "'ToModule1|ToModule2|ToModule3'.", null);
    UnitTestTreeLogger logger = builder.createLogger();
    File missingDepsFile = java.nio.file.Files.createTempFile("missingDepsFile", "txt").toFile();
    MockDepsInfoProvider depsInfo = new MockDepsInfoProvider();
    depsInfo.addModuleDep("FooModule", "FromModule1");
    depsInfo.addModuleDep("FooModule", "FromModule2");
    depsInfo.addModuleDep("FooModule", "FromModule3");
    depsInfo.addModuleDep("FooModule", "ToModule1");
    depsInfo.addModuleDep("FooModule", "ToModule2");
    depsInfo.addModuleDep("FooModule", "ToModule3");
    // Notice that FromModule2 can see just ToModule2 while the rest are completely blind.
    depsInfo.addModuleDep("FromModule2", "ToModule2");
    depsInfo.addGwtXmlFile("FromModule1", "com/google/gwt/FromModule1.gwt.xml");
    depsInfo.addGwtXmlFile("FromModule2", "com/google/gwt/FromModule2.gwt.xml");
    depsInfo.addGwtXmlFile("FromModule3", "com/google/gwt/FromModule3.gwt.xml");
    depsInfo.addGwtXmlFile("ToModule1", "com/google/gwt/ToModule1.gwt.xml");
    depsInfo.addGwtXmlFile("ToModule2", "com/google/gwt/ToModule2.gwt.xml");
    depsInfo.addGwtXmlFile("ToModule3", "com/google/gwt/ToModule3.gwt.xml");
    depsInfo.registerType("FromType", "FromModule1");
    depsInfo.registerType("FromType", "FromModule2");
    depsInfo.registerType("FromType", "FromModule3");
    depsInfo.registerType("ToType", "ToModule1");
    depsInfo.registerType("ToType", "ToModule2");
    depsInfo.registerType("ToType", "ToModule3");
    TypeRefDepsChecker typeRefDepsChecker =
        new TypeRefDepsChecker(logger, null, depsInfo, true, missingDepsFile);
    typeRefDepsChecker.maybeRecordTypeRef("FromType", "ToType");

    // Run typeRefDepsChecker.
    typeRefDepsChecker.verifyTypeRefsInModules();

    // Verify results.
    logger.assertCorrectLogEntries();
    assertEquals(
         // Line 1.
        "FromModule1\tcom/google/gwt/FromModule1.gwt.xml\t"
        + "ToModule1|ToModule2|ToModule3\tcom/google/gwt/ToModule1.gwt.xml|"
        + "com/google/gwt/ToModule2.gwt.xml|com/google/gwt/ToModule3.gwt.xml\t"
View Full Code Here

        CharMatcher.WHITESPACE.trimFrom(Files.toString(missingDepsFile, Charsets.UTF_8)));
  }

  public void testOptionsDisabled() {
    // Setup environment.
    UnitTestTreeLogger logger = new UnitTestTreeLogger.Builder().createLogger();
    MockDepsInfoProvider depsInfo = new MockDepsInfoProvider();
    // Notice that BarModule can not see BazModule.
    depsInfo.addModuleDep("FooModule", "BarModule");
    depsInfo.addModuleDep("FooModule", "BazModule");
    depsInfo.addGwtXmlFile("FooModule", "com/google/gwt/FooModule.gwt.xml");
    depsInfo.addGwtXmlFile("BarModule", "com/google/gwt/BarModule.gwt.xml");
    depsInfo.addGwtXmlFile("BazModule", "com/google/gwt/BazModule.gwt.xml");
    depsInfo.registerType("BangType", "BarModule");
    depsInfo.registerType("ZingType", "BazModule");
    TypeRefDepsChecker typeRefDepsChecker =
        new TypeRefDepsChecker(logger, null, depsInfo, false, null);
    // Make a type from BarModule depend on a type from BazModule.
    typeRefDepsChecker.maybeRecordTypeRef("BangType", "ZingType");

    // Run typeRefDepsChecker.
    typeRefDepsChecker.verifyTypeRefsInModules();

    // Verify results.
    logger.assertCorrectLogEntries();
  }
View Full Code Here

    // Setup environment.
    UnitTestTreeLogger.Builder builder = new UnitTestTreeLogger.Builder();
    builder.expectWarn(
        "Type 'BangType' wants to reference type 'ZingType' but can't because module "
        + "'BarModule' has no dependency (neither direct nor transitive) on 'BazModule'.", null);
    UnitTestTreeLogger logger = builder.createLogger();
    File missingDepsFile = java.nio.file.Files.createTempFile("missingDepsFile", "txt").toFile();
    MockDepsInfoProvider depsInfo = new MockDepsInfoProvider();
    // Notice that BarModule can not see BazModule.
    depsInfo.addModuleDep("FooModule", "BarModule");
    depsInfo.addModuleDep("FooModule", "BazModule");
    depsInfo.addGwtXmlFile("FooModule", "com/google/gwt/FooModule.gwt.xml");
    depsInfo.addGwtXmlFile("BarModule", "com/google/gwt/BarModule.gwt.xml");
    depsInfo.addGwtXmlFile("BazModule", "com/google/gwt/BazModule.gwt.xml");
    depsInfo.registerType("BangType", "BarModule");
    depsInfo.registerType("ZingType", "BazModule");
    TypeRefDepsChecker typeRefDepsChecker =
        new TypeRefDepsChecker(logger, null, depsInfo, true, missingDepsFile);
    // Make a type from BarModule depend on a type from BazModule.
    typeRefDepsChecker.maybeRecordTypeRef("BangType", "ZingType");

    // Run typeRefDepsChecker.
    typeRefDepsChecker.verifyTypeRefsInModules();

    // Verify results.
    logger.assertCorrectLogEntries();
    assertEquals(
        "BarModule\tcom/google/gwt/BarModule.gwt.xml\tBazModule\tcom/google/gwt/BazModule.gwt.xml"
        + "\tType 'BangType' wants to reference type 'ZingType'.",
        CharMatcher.WHITESPACE.trimFrom(Files.toString(missingDepsFile, Charsets.UTF_8)));
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.util.UnitTestTreeLogger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.