Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1065)

Unified Diff: compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java

Issue 10389206: Issue 3123. Catch exceptions in Source.exists()/initProperties() (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java
diff --git a/compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java b/compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java
index d6bde06bae444d52236e97a7b56676d7b4d69794..a9b7f4cefab6cf5f2dd4e2425092cd57660f09f5 100644
--- a/compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java
+++ b/compiler/javatests/com/google/dart/compiler/end2end/inc/IncrementalCompilation2Test.java
@@ -9,6 +9,7 @@ import static com.google.dart.compiler.common.ErrorExpectation.assertErrors;
import static com.google.dart.compiler.common.ErrorExpectation.errEx;
import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
import com.google.dart.compiler.CompilerTestCase;
import com.google.dart.compiler.DartCompilationError;
import com.google.dart.compiler.DartCompiler;
@@ -19,7 +20,10 @@ import com.google.dart.compiler.DefaultCompilerConfiguration;
import com.google.dart.compiler.LibrarySource;
import com.google.dart.compiler.MockArtifactProvider;
import com.google.dart.compiler.Source;
+import com.google.dart.compiler.SystemLibraryManager;
+import com.google.dart.compiler.UrlSource;
import com.google.dart.compiler.ast.DartUnit;
+import com.google.dart.compiler.ast.LibraryUnit;
import com.google.dart.compiler.resolver.ResolverErrorCode;
import com.google.dart.compiler.resolver.TypeErrorCode;
@@ -28,6 +32,7 @@ import junit.framework.AssertionFailedError;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
+import java.net.URI;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet;
@@ -630,10 +635,6 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
errEx("B.dart", ResolverErrorCode.DUPLICATE_TOP_LEVEL_DECLARATION, 3, 5, 7));
}
- /**
- * Test that invalid "#source" is reported as any other error between "unitAboutToCompile" and
- * "unitCompiled".
- */
public void test_reportMissingSource() throws Exception {
appSource.setContent(
APP,
@@ -642,31 +643,33 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
"#library('app');",
"#source('noSuchUnit.dart');",
""));
- // Remember errors only between unitAboutToCompile/unitCompiled.
- errors.clear();
- DartCompilerListener listener = new DartCompilerListener.Empty() {
- boolean isCompiling = false;
-
+ compile();
+ // Check that errors where reported (and in correct time).
+ assertErrors(errors, errEx(DartCompilerErrorCode.MISSING_SOURCE, 3, 1, 27));
+ }
+
+ public void test_reportMissingSource_withSchema_file() throws Exception {
+ URI uri = new URI("file:noSuchSource.dart");
+ Source source = new UrlSource(uri) {
@Override
- public void unitAboutToCompile(DartSource source, boolean diet) {
- isCompiling = true;
+ public String getName() {
+ return null;
}
-
- @Override
- public void onError(DartCompilationError event) {
- if (isCompiling) {
- errors.add(event);
- }
- }
-
+ };
+ // should not cause exception
+ assertFalse(source.exists());
+ }
+
+ public void test_reportMissingSource_withSchema_dart() throws Exception {
+ URI uri = new URI("dart:noSuchSource");
+ Source source = new UrlSource(uri, new SystemLibraryManager()) {
@Override
- public void unitCompiled(DartUnit unit) {
- isCompiling = false;
+ public String getName() {
+ return null;
}
};
- DartCompiler.compileLib(appSource, config, provider, listener);
- // Check that errors where reported (and in correct time).
- assertErrors(errors, errEx(DartCompilerErrorCode.MISSING_SOURCE, 3, 1, 27));
+ // should not cause exception
+ assertFalse(source.exists());
}
/**
@@ -708,9 +711,24 @@ public class IncrementalCompilation2Test extends CompilerTestCase {
provider.resetReadsAndWrites();
errors.clear();
DartCompilerListener listener = new DartCompilerListener.Empty() {
+ Set<URI> compilingUris = Sets.newHashSet();
+
+ @Override
+ public void unitAboutToCompile(DartSource source, boolean diet) {
+ compilingUris.add(source.getUri());
+ }
+
@Override
public void onError(DartCompilationError event) {
- errors.add(event);
+ // Remember errors only between unitAboutToCompile/unitCompiled.
+ if (compilingUris.contains(event.getSource().getUri())) {
+ errors.add(event);
+ }
+ }
+
+ @Override
+ public void unitCompiled(DartUnit unit) {
+ compilingUris.remove(unit.getSourceInfo().getSource().getUri());
}
};
DartCompiler.compileLib(lib, config, provider, listener);

Powered by Google App Engine
This is Rietveld 408576698