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

Side by Side Diff: compiler/javatests/com/google/dart/corelib/SharedTestCase.java

Issue 9466041: Removes dependency on v8 from dartc testing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated date, copyright notices, build.xml Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 package com.google.dart.corelib; 5 package com.google.dart.corelib;
6 6
7 import com.google.dart.compiler.AnalysisError;
7 import com.google.dart.compiler.CommandLineOptions.CompilerOptions; 8 import com.google.dart.compiler.CommandLineOptions.CompilerOptions;
8 import com.google.dart.compiler.CompilerConfiguration; 9 import com.google.dart.compiler.CompilerConfiguration;
9 import com.google.dart.compiler.DartArtifactProvider; 10 import com.google.dart.compiler.DartArtifactProvider;
10 import com.google.dart.compiler.DartCompilationError; 11 import com.google.dart.compiler.DartCompilationError;
11 import com.google.dart.compiler.DartCompiler; 12 import com.google.dart.compiler.DartCompiler;
12 import com.google.dart.compiler.DartCompilerListener; 13 import com.google.dart.compiler.DartCompilerListener;
13 import com.google.dart.compiler.DefaultCompilerConfiguration; 14 import com.google.dart.compiler.DefaultCompilerConfiguration;
14 import com.google.dart.compiler.DefaultDartArtifactProvider; 15 import com.google.dart.compiler.DefaultDartArtifactProvider;
15 import com.google.dart.compiler.DefaultLibrarySource; 16 import com.google.dart.compiler.DefaultLibrarySource;
16 import com.google.dart.compiler.ErrorSeverity; 17 import com.google.dart.compiler.ErrorSeverity;
17 import com.google.dart.compiler.LibrarySource; 18 import com.google.dart.compiler.LibrarySource;
18 import com.google.dart.compiler.Source; 19 import com.google.dart.compiler.Source;
19 import com.google.dart.compiler.SubSystem; 20 import com.google.dart.compiler.SubSystem;
20 import com.google.dart.compiler.UrlLibrarySource; 21 import com.google.dart.compiler.UrlLibrarySource;
21 import com.google.dart.runner.DartRunner;
22 import com.google.dart.runner.RunnerError;
23 import com.google.dart.runner.V8Launcher;
24 22
25 import junit.framework.AssertionFailedError; 23 import junit.framework.AssertionFailedError;
26 import junit.framework.Test; 24 import junit.framework.Test;
27 import junit.framework.TestCase; 25 import junit.framework.TestCase;
28 import junit.framework.TestSuite; 26 import junit.framework.TestSuite;
29 27
30 import org.kohsuke.args4j.CmdLineException; 28 import org.kohsuke.args4j.CmdLineException;
31 import org.kohsuke.args4j.CmdLineParser; 29 import org.kohsuke.args4j.CmdLineParser;
32 30
33 import java.io.ByteArrayOutputStream; 31 import java.io.ByteArrayOutputStream;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 return super.getName() + " " + remarks; 124 return super.getName() + " " + remarks;
127 } 125 }
128 } 126 }
129 127
130 String getScrubbedName() { 128 String getScrubbedName() {
131 return super.getName(); 129 return super.getName();
132 } 130 }
133 131
134 @Override 132 @Override
135 public void runBare() { 133 public void runBare() {
136 assertTrue(V8Launcher.isConfigured());
137 ByteArrayOutputStream byteOutput = new ByteArrayOutputStream(); 134 ByteArrayOutputStream byteOutput = new ByteArrayOutputStream();
138 PrintStream outputStream = new PrintStream(byteOutput); 135 PrintStream outputStream = new PrintStream(byteOutput);
139 try { 136 try {
140 if (regularCompile) { 137 invokeCompiler();
141 invokeCompiler(); 138 } catch (AnalysisError e) {
142 } else {
143 DartRunner.throwingMain(arguments, outputStream, outputStream);
144 }
145 } catch (RunnerError e) {
146 outputStream.close(); 139 outputStream.close();
147 analyzeError(e, byteOutput.toString()); 140 analyzeError(e, byteOutput.toString());
148 return; 141 return;
149 } catch (Throwable t) { 142 } catch (Throwable t) {
150 outputStream.close(); 143 outputStream.close();
151 analyzeCrash(t); 144 analyzeCrash(t);
152 return; 145 return;
153 } 146 }
154 outputStream.close(); 147 outputStream.close();
155 analyzeNormalCompletion(); 148 analyzeNormalCompletion();
156 } 149 }
157 150
158 private void invokeCompiler() throws CmdLineException, IOException, RunnerErro r { 151 private void invokeCompiler() throws CmdLineException, IOException, AnalysisEr ror {
159 CmdLineParser cmdLineParser = null; 152 CmdLineParser cmdLineParser = null;
160 CompilerOptions compilerOptions = new CompilerOptions(); 153 CompilerOptions compilerOptions = new CompilerOptions();
161 cmdLineParser = new CmdLineParser(compilerOptions); 154 cmdLineParser = new CmdLineParser(compilerOptions);
162 cmdLineParser.parseArgument(arguments); 155 cmdLineParser.parseArgument(arguments);
163 CompilerConfiguration config = new DefaultCompilerConfiguration(compilerOpti ons); 156 CompilerConfiguration config = new DefaultCompilerConfiguration(compilerOpti ons);
164 DartArtifactProvider provider = getArtifactProvider(config.getOutputDirector y()); 157 DartArtifactProvider provider = getArtifactProvider(config.getOutputDirector y());
165 DartCompilerListener listener = getListener(); 158 DartCompilerListener listener = getListener();
166 List<String> sourceFiles = compilerOptions.getSourceFiles(); 159 List<String> sourceFiles = compilerOptions.getSourceFiles();
167 assertEquals("incorrect number of source files " + sourceFiles, 1, sourceFil es.size()); 160 assertEquals("incorrect number of source files " + sourceFiles, 1, sourceFil es.size());
168 File sourceFile = new File(sourceFiles.get(0)); 161 File sourceFile = new File(sourceFiles.get(0));
169 LibrarySource lib; 162 LibrarySource lib;
170 if (sourceFile.getName().endsWith(".dart")) { 163 if (sourceFile.getName().endsWith(".dart")) {
171 lib = new DefaultLibrarySource(sourceFile, null); 164 lib = new DefaultLibrarySource(sourceFile, null);
172 } else { 165 } else {
173 lib = new UrlLibrarySource(sourceFile); 166 lib = new UrlLibrarySource(sourceFile);
174 } 167 }
175 DartCompiler.compileLib(lib, config, provider, listener); 168 DartCompiler.compileLib(lib, config, provider, listener);
176 if (compilationErrorCount.get() != 0 || typeErrorCount.get() != 0 || warning Count.get() != 0) { 169 if (compilationErrorCount.get() != 0 || typeErrorCount.get() != 0 || warning Count.get() != 0) {
177 throw new RunnerError(sourceFile.getPath()); 170 throw new AnalysisError(sourceFile.getPath());
178 } 171 }
179 } 172 }
180 173
181 private DartArtifactProvider getArtifactProvider(File outputDirectory) { 174 private DartArtifactProvider getArtifactProvider(File outputDirectory) {
182 final DartArtifactProvider provider = new DefaultDartArtifactProvider(output Directory); 175 final DartArtifactProvider provider = new DefaultDartArtifactProvider(output Directory);
183 return new DartArtifactProvider() { 176 return new DartArtifactProvider() {
184 ConcurrentHashMap<URI, CharArrayWriter> artifacts = 177 ConcurrentHashMap<URI, CharArrayWriter> artifacts =
185 new ConcurrentHashMap<URI, CharArrayWriter>(); 178 new ConcurrentHashMap<URI, CharArrayWriter>();
186 179
187 @Override 180 @Override
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 private void analyzeCrash(Throwable t) { 251 private void analyzeCrash(Throwable t) {
259 if (outcomes.contains("crash")) { 252 if (outcomes.contains("crash")) {
260 return; 253 return;
261 } 254 }
262 String message = outcomes.contains("fail") ? "Failing test crashed" : "Test crashed unexpectly"; 255 String message = outcomes.contains("fail") ? "Failing test crashed" : "Test crashed unexpectly";
263 AssertionFailedError error = new AssertionFailedError(message); 256 AssertionFailedError error = new AssertionFailedError(message);
264 error.initCause(t); 257 error.initCause(t);
265 throw error; 258 throw error;
266 } 259 }
267 260
268 private void analyzeError(RunnerError e, String log) { 261 private void analyzeError(AnalysisError e, String log) {
269 if (isNegative) { 262 if (isNegative) {
270 if (!outcomes.contains("pass")) { 263 if (!outcomes.contains("pass")) {
271 fail("Negative test is passing, please update status file"); 264 fail("Negative test is passing, please update status file");
272 } 265 }
273 } else { 266 } else {
274 if (!outcomes.contains("fail")) { 267 if (!outcomes.contains("fail")) {
275 fail(log + e.getLocalizedMessage()); 268 fail(log + e.getLocalizedMessage());
276 } 269 }
277 } 270 }
278 } 271 }
279 272
280 static Test getInstance(String line, boolean regularCompile) { 273 static Test getInstance(String line, boolean regularCompile) {
281 String[] fields = SEPARATOR.split(line); 274 String[] fields = SEPARATOR.split(line);
282 if (fields.length <= 3) { 275 if (fields.length <= 3) {
283 fail("Line is not parsable: " + line); 276 fail("Line is not parsable: " + line);
284 } 277 }
285 String name = fields[0]; 278 String name = fields[0];
286 Set<String> outcomes = new HashSet<String>(Arrays.<String>asList(fields[1].s plit(","))); 279 Set<String> outcomes = new HashSet<String>(Arrays.<String>asList(fields[1].s plit(",")));
287 boolean isNegative = fields[2].equals("True"); 280 boolean isNegative = fields[2].equals("True");
288 String[] arguments = new String[fields.length - 3]; 281 String[] arguments = new String[fields.length - 3];
289 System.arraycopy(fields, 3, arguments, 0, arguments.length); 282 System.arraycopy(fields, 3, arguments, 0, arguments.length);
290 return new SharedTestCase(name, outcomes, isNegative, regularCompile, argume nts) {}; 283 return new SharedTestCase(name, outcomes, isNegative, regularCompile, argume nts) {};
291 } 284 }
292 } 285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698