| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #library("stub_generator_test_config"); | 5 #library("stub_generator_test_config"); |
| 6 | 6 |
| 7 #import("../../tools/testing/dart/test_suite.dart"); | 7 #import("../../tools/testing/dart/test_suite.dart"); |
| 8 | 8 |
| 9 class StubGeneratorTestSuite extends StandardTestSuite { | 9 class StubGeneratorTestSuite extends StandardTestSuite { |
| 10 String dartcPath; | 10 String dartcPath; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 resultStream.close(); | 94 resultStream.close(); |
| 95 onGenerated(resultPath); | 95 onGenerated(resultPath); |
| 96 }; | 96 }; |
| 97 } | 97 } |
| 98 | 98 |
| 99 void generateTestCase(String filename, | 99 void generateTestCase(String filename, |
| 100 String interfaceFile, | 100 String interfaceFile, |
| 101 String classes, | 101 String classes, |
| 102 Function onGenerated) { | 102 Function onGenerated) { |
| 103 testGeneratorStarted(); | 103 testGeneratorStarted(); |
| 104 Directory temp = createOutputDirectory(interfaceFile, ''); | 104 Directory temp = createOutputDirectory(filename, 'stub_generator'); |
| 105 | 105 |
| 106 File stubsOutFile = new File("${temp.path}/${interfaceFile}"); | 106 File stubsOutFile = new File("${temp.path}/${interfaceFile}"); |
| 107 stubsOutFile.createSync(); | 107 stubsOutFile.createSync(); |
| 108 String stubsPath = stubsOutFile.fullPathSync(); | 108 String stubsPath = stubsOutFile.fullPathSync(); |
| 109 List<String> args = [filename, | 109 List<String> args = [filename, |
| 110 '-noincremental', | 110 '-noincremental', |
| 111 '-out', temp.path, | 111 '-out', temp.path, |
| 112 '-isolate-stub-out', stubsPath, | 112 '-isolate-stub-out', stubsPath, |
| 113 '-generate-isolate-stubs', classes ]; | 113 '-generate-isolate-stubs', classes ]; |
| 114 if (configuration['verbose']) { | 114 if (configuration['verbose']) { |
| 115 print("# $dartcPath ${Strings.join(args, ' ')}"); | 115 print("# $dartcPath ${Strings.join(args, ' ')}"); |
| 116 } | 116 } |
| 117 Process dartcProcess = new Process.start(dartcPath, args); | 117 Process dartcProcess = new Process.start(dartcPath, args); |
| 118 dartcProcess.exitHandler = (int exitCode) { | 118 dartcProcess.exitHandler = (int exitCode) { |
| 119 combineFiles(filename, stubsPath, onGenerated); | 119 combineFiles(filename, stubsPath, onGenerated); |
| 120 }; | 120 }; |
| 121 } | 121 } |
| 122 | 122 |
| 123 void processFile(String filename) { | 123 void processFile(String filename) { |
| 124 filename = filename.replaceAll('\\', '/') ; |
| 124 // Only run the tests that match the pattern. | 125 // Only run the tests that match the pattern. |
| 125 RegExp pattern = configuration['selectors'][suiteName]; | 126 RegExp pattern = configuration['selectors'][suiteName]; |
| 126 if (!pattern.hasMatch(filename)) return; | 127 if (!pattern.hasMatch(filename)) return; |
| 127 var optionsFromFile = optionsFromFile(filename); | 128 var optionsFromFile = optionsFromFile(filename); |
| 128 Function createTestCase = makeTestCaseCreator(optionsFromFile); | 129 Function createTestCase = makeTestCaseCreator(optionsFromFile); |
| 129 | 130 |
| 130 if (filename.endsWith("-generatedTest.dart")) { | 131 if (filename.endsWith("-generatedTest.dart")) { |
| 131 if (dartcPath == null) { | 132 if (dartcPath == null) { |
| 132 createTestCase(filename, optionsFromFile['isNegative']); | 133 createTestCase(filename, optionsFromFile['isNegative']); |
| 133 } | 134 } |
| 134 } else if (filename.endsWith("Test.dart")) { | 135 } else if (filename.endsWith("Test.dart")) { |
| 135 if (dartcPath != null) { | 136 if (dartcPath != null) { |
| 136 String isolateStubsOptions = optionsFromFile['isolateStubs']; | 137 String isolateStubsOptions = optionsFromFile['isolateStubs']; |
| 137 List<String> splitIsolateStubsOptions = isolateStubsOptions.split(':'); | 138 List<String> splitIsolateStubsOptions = isolateStubsOptions.split(':'); |
| 138 Expect.equals(2, splitIsolateStubsOptions.length); | 139 Expect.equals(2, splitIsolateStubsOptions.length); |
| 139 String interfaceFile = splitIsolateStubsOptions[0]; | 140 String interfaceFile = splitIsolateStubsOptions[0]; |
| 140 String classes = splitIsolateStubsOptions[1]; | 141 String classes = splitIsolateStubsOptions[1]; |
| 141 generateTestCase(filename, interfaceFile, classes, (String filename) { | 142 generateTestCase(filename, interfaceFile, classes, (String filename) { |
| 142 createTestCase(filename, optionsFromFile['isNegative']); | 143 createTestCase(filename, optionsFromFile['isNegative']); |
| 143 testGeneratorDone(); | 144 testGeneratorDone(); |
| 144 }); | 145 }); |
| 145 } | 146 } |
| 146 } | 147 } |
| 147 } | 148 } |
| 148 } | 149 } |
| OLD | NEW |