| 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; |
| 11 | 11 |
| 12 StubGeneratorTestSuite(Map configuration) | 12 StubGeneratorTestSuite(Map configuration) |
| 13 : super(configuration, | 13 : super(configuration, |
| 14 "stub-generator", | 14 "stub-generator", |
| 15 "tests/stub-generator/src", | 15 "tests/stub-generator/src", |
| 16 ["tests/stub-generator/stub-generator.status"]) { | 16 ["tests/stub-generator/stub-generator.status"]) { |
| 17 try { | 17 try { |
| 18 dartcPath = TestUtils.compilerPath(configuration); | 18 dartcPath = TestUtils.compilerPath(configuration); |
| 19 } catch (var e) { | 19 } catch (var e) { |
| 20 // ignore | 20 // ignore |
| 21 } | 21 } |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool get requiresCleanTemporaryDirectory() => true; |
| 25 |
| 24 void combineFiles(String filename, | 26 void combineFiles(String filename, |
| 25 String stubsFile, | 27 String stubsFile, |
| 26 Function onGenerated) { | 28 Function onGenerated) { |
| 27 File orig = new File(filename); | 29 File orig = new File(filename); |
| 28 File stubs = new File(stubsFile); | 30 File stubs = new File(stubsFile); |
| 29 Expect.isTrue(filename.endsWith(".dart")); | 31 Expect.isTrue(filename.endsWith(".dart")); |
| 30 String baseName = filename.substring(0, filename.length - 5); | 32 String baseName = filename.substring(0, filename.length - 5); |
| 31 String resultPath = '${baseName}-generatedTest.dart'; | 33 String resultPath = '${baseName}-generatedTest.dart'; |
| 32 File result = new File(resultPath); | 34 File result = new File(resultPath); |
| 33 StringInputStream origStream = | 35 StringInputStream origStream = |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 resultStream.close(); | 94 resultStream.close(); |
| 93 onGenerated(resultPath); | 95 onGenerated(resultPath); |
| 94 }; | 96 }; |
| 95 } | 97 } |
| 96 | 98 |
| 97 void generateTestCase(String filename, | 99 void generateTestCase(String filename, |
| 98 String interfaceFile, | 100 String interfaceFile, |
| 99 String classes, | 101 String classes, |
| 100 Function onGenerated) { | 102 Function onGenerated) { |
| 101 testGeneratorStarted(); | 103 testGeneratorStarted(); |
| 102 Directory temp = new Directory(''); | 104 Directory temp = createOutputDirectory(interfaceFile, ''); |
| 103 temp.createTempSync(); | 105 |
| 104 File stubsOutFile = new File("${temp.path}/${interfaceFile}"); | 106 File stubsOutFile = new File("${temp.path}/${interfaceFile}"); |
| 105 stubsOutFile.createSync(); | 107 stubsOutFile.createSync(); |
| 106 String stubsPath = stubsOutFile.fullPathSync(); | 108 String stubsPath = stubsOutFile.fullPathSync(); |
| 107 List<String> args = [filename, | 109 List<String> args = [filename, |
| 108 '-noincremental', | 110 '-noincremental', |
| 109 '-out', temp.path, | 111 '-out', temp.path, |
| 110 '-isolate-stub-out', stubsPath, | 112 '-isolate-stub-out', stubsPath, |
| 111 '-generate-isolate-stubs', classes ]; | 113 '-generate-isolate-stubs', classes ]; |
| 112 if (configuration['verbose']) { | 114 if (configuration['verbose']) { |
| 113 print("# $dartcPath ${Strings.join(args, ' ')}"); | 115 print("# $dartcPath ${Strings.join(args, ' ')}"); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 137 String interfaceFile = splitIsolateStubsOptions[0]; | 139 String interfaceFile = splitIsolateStubsOptions[0]; |
| 138 String classes = splitIsolateStubsOptions[1]; | 140 String classes = splitIsolateStubsOptions[1]; |
| 139 generateTestCase(filename, interfaceFile, classes, (String filename) { | 141 generateTestCase(filename, interfaceFile, classes, (String filename) { |
| 140 createTestCase(filename, optionsFromFile['isNegative']); | 142 createTestCase(filename, optionsFromFile['isNegative']); |
| 141 testGeneratorDone(); | 143 testGeneratorDone(); |
| 142 }); | 144 }); |
| 143 } | 145 } |
| 144 } | 146 } |
| 145 } | 147 } |
| 146 } | 148 } |
| OLD | NEW |