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

Unified Diff: tests/stub-generator/test_config.dart

Issue 9371018: Remove stub-generation test for dartc from test.dart stub-generator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/stub-generator/test_config.dart
diff --git a/tests/stub-generator/test_config.dart b/tests/stub-generator/test_config.dart
index 94e42b8514721b296e6d8e7065d4508e5d5abb14..e22bdece50fff95e9a5c27e00958f01ed4722169 100644
--- a/tests/stub-generator/test_config.dart
+++ b/tests/stub-generator/test_config.dart
@@ -4,161 +4,14 @@
#library("stub_generator_test_config");
-#import("dart:io");
-
#import("../../tools/testing/dart/test_suite.dart");
class StubGeneratorTestSuite extends StandardTestSuite {
- String dartcPath;
-
StubGeneratorTestSuite(Map configuration)
: super(configuration,
"stub-generator",
"tests/stub-generator/src",
- ["tests/stub-generator/stub-generator.status"]) {
- try {
- dartcPath = TestUtils.compilerPath(configuration);
- } catch (var e) {
- // ignore
- }
- }
-
- bool get requiresCleanTemporaryDirectory() => true;
-
- void combineFiles(String filename,
- String stubsFile,
- Function onGenerated) {
- File orig = new File(filename);
- File stubs = new File(stubsFile);
- Expect.isTrue(filename.endsWith(".dart"));
- String baseName = filename.substring(0, filename.length - 5);
- // Find place in the buildDir at the same relative level as the test.
- String resultPath = TestUtils.buildDir(configuration);
- String relativeImportPath = '../../../tests/isolate/src/TestFramework.dart';
- if (!new File('$resultPath/$relativeImportPath').existsSync()) {
- resultPath = '$resultPath/generated_tests';
- if (!new Directory(resultPath).existsSync()) {
- new Directory(resultPath).createSync();
- }
- if (!new File('$resultPath/$relativeImportPath').existsSync()) {
- throw new Exception('Cannot find $relativeImportPath from $resultPath');
- }
- }
- int testNamePos = filename.lastIndexOf('/');
- resultPath = '$resultPath/${filename.substring(testNamePos + 1)}';
- File result = new File(resultPath);
- StringInputStream origStream =
- new StringInputStream(orig.openInputStream());
- StringInputStream stubsStream =
- new StringInputStream(stubs.openInputStream());
- OutputStream resultStream = result.openOutputStream();
- var origLine;
-
- void writeResultLine(String line) {
- resultStream.write(line.charCodes());
- resultStream.write('\n'.charCodes());
- }
-
- // Step 3: Copy in the rest of the original file.
- void copyThirdPart() {
- origLine = origStream.readLine();
- while (origLine != null) {
- writeResultLine(origLine);
- origLine = origStream.readLine();
- }
- }
-
- // Step 2: Copy in the generated stubs code.
- void copySecondPart() {
- var stubsLine = stubsStream.readLine();
- while (stubsLine != null) {
- writeResultLine(stubsLine);
- stubsLine = stubsStream.readLine();
- }
- }
-
- // Step 1: Copy first comments and imports from original file.
- void copyFirstPart() {
- origLine = origStream.readLine();
- while (origLine != null) {
- origLine = origLine.trim();
- if (origLine.isEmpty() ||
- origLine.startsWith('//') ||
- origLine.startsWith('#')) {
- writeResultLine(origLine);
- origLine = origStream.readLine();
- } else {
- origStream.lineHandler = null;
- // Start copying from the stubs file.
- stubsStream.lineHandler = copySecondPart;
- stubsStream.closeHandler = () {
- // When the stubs file is all read continue with the rest
- // of the original file including the pending line.
- writeResultLine(origLine);
- origStream.lineHandler = copyThirdPart;
- };
- return;
- }
- }
- }
-
- origStream.lineHandler = copyFirstPart;
- origStream.closeHandler = () {
- // Done generating file when all data has been read from the
- // original file.
- resultStream.close();
- onGenerated(resultPath);
- };
- }
-
- void generateTestCase(String filename,
- String interfaceFile,
- String classes,
- Function onGenerated) {
- testGeneratorStarted();
- Directory temp = createOutputDirectory(filename, 'stub_generator');
-
- File stubsOutFile = new File("${temp.path}/${interfaceFile}");
- stubsOutFile.createSync();
- String stubsPath = stubsOutFile.fullPathSync();
- List<String> args = [filename,
- '-noincremental',
- '-out', temp.path,
- '-isolate-stub-out', stubsPath,
- '-generate-isolate-stubs', classes ];
- if (configuration['verbose']) {
- print("# $dartcPath ${Strings.join(args, ' ')}");
- }
- Process dartcProcess = new Process.start(dartcPath, args);
- dartcProcess.exitHandler = (int exitCode) {
- combineFiles(filename, stubsPath, onGenerated);
- };
- }
-
- void processFile(String filename) {
- filename = filename.replaceAll('\\', '/') ;
- // Only run the tests that match the pattern.
- RegExp pattern = configuration['selectors'][suiteName];
- if (!pattern.hasMatch(filename)) return;
- var optionsFromFile = optionsFromFile(filename);
- Function createTestCase = makeTestCaseCreator(optionsFromFile);
+ ["tests/stub-generator/stub-generator.status"]);
- if (filename.endsWith("-generatedTest.dart")) {
- if (dartcPath == null) {
- createTestCase(filename, optionsFromFile['isNegative']);
- }
- } else if (filename.endsWith("Test.dart")) {
- if (dartcPath != null) {
- String isolateStubsOptions = optionsFromFile['isolateStubs'];
- List<String> splitIsolateStubsOptions = isolateStubsOptions.split(':');
- Expect.equals(2, splitIsolateStubsOptions.length);
- String interfaceFile = splitIsolateStubsOptions[0];
- String classes = splitIsolateStubsOptions[1];
- generateTestCase(filename, interfaceFile, classes, (String filename) {
- createTestCase(filename, optionsFromFile['isNegative']);
- testGeneratorDone();
- });
- }
- }
- }
+ bool isTestFile(String filename) => filename.endsWith("-generatedTest.dart");
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698