| 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("multitest"); | 5 #library("multitest"); |
| 6 | 6 |
| 7 #import("dart:io"); | 7 #import("dart:io"); |
| 8 #import("test_suite.dart"); | 8 #import("test_suite.dart"); |
| 9 | 9 |
| 10 // Multitests are Dart test scripts containing lines of the form | 10 // Multitests are Dart test scripts containing lines of the form |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 // Matches #import( or #source( followed by " or ' followed by anything | 123 // Matches #import( or #source( followed by " or ' followed by anything |
| 124 // except dart: or /, at the beginning of a line. | 124 // except dart: or /, at the beginning of a line. |
| 125 RegExp relativeImportRegExp = | 125 RegExp relativeImportRegExp = |
| 126 const RegExp('^#(import|source)[(]["\'](?!(dart:|/))([^"\']*)["\']'); | 126 const RegExp('^#(import|source)[(]["\'](?!(dart:|/))([^"\']*)["\']'); |
| 127 while (!toSearch.isEmpty()) { | 127 while (!toSearch.isEmpty()) { |
| 128 var thisPass = toSearch; | 128 var thisPass = toSearch; |
| 129 toSearch = new HashSet<String>(); | 129 toSearch = new HashSet<String>(); |
| 130 for (String filename in thisPass) { | 130 for (String filename in thisPass) { |
| 131 File f = new File(filename); | 131 File f = new File(filename); |
| 132 for (String line in f.readAsLinesSync()) { | 132 for (String line in f.readAsLinesSync()) { |
| 133 Match match = relativeImportRegExp.firstMatch(line); | 133 Match match = relativeImportRegExp.firstMatch(line); |
| 134 if (match != null) { | 134 if (match != null) { |
| 135 String relativePath = match.group(3); | 135 String relativePath = match.group(3); |
| 136 if (foundImports.contains(relativePath)) { | 136 if (foundImports.contains(relativePath)) { |
| 137 continue; | 137 continue; |
| 138 } | 138 } |
| 139 if (relativePath.contains(@'\.\.')) { | 139 if (relativePath.contains(@'\.\.')) { |
| 140 // This is just for safety reasons, we don't want | 140 // This is just for safety reasons, we don't want |
| 141 // to unintentionally clobber files relative to the destination | 141 // to unintentionally clobber files relative to the destination |
| 142 // dir when copying them ove. | 142 // dir when copying them ove. |
| 143 Expect.fail("relative paths containing .. are not allowed."); | 143 Expect.fail("relative paths containing .. are not allowed."); |
| 144 } | 144 } |
| 145 foundImports.add(relativePath); | 145 foundImports.add(relativePath); |
| 146 toSearch.add('$libraryDir/$relativePath'); | 146 toSearch.add('$libraryDir/$relativePath'); |
| 147 } | 147 } |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 return foundImports; | 151 return foundImports; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void DoMultitest(String filename, | 154 void DoMultitest(String filename, |
| 155 String outputDir, | 155 String outputDir, |
| 156 String testDir, | 156 String testDir, |
| 157 // TODO(zundel): Are the boolean flags now redundant | 157 // TODO(zundel): Are the boolean flags now redundant |
| 158 // with the 'multitestOutcome' field? | 158 // with the 'multitestOutcome' field? |
| 159 Function doTest(String filename, | 159 Function doTest(String filename, |
| 160 bool isNegative, | 160 bool isNegative, |
| 161 [bool isNegativeIfChecked, | 161 [bool isNegativeIfChecked, |
| 162 bool hasFatalTypeErrors, | 162 bool hasFatalTypeErrors, |
| 163 bool hasRuntimeErrors, | 163 bool hasRuntimeErrors, |
| 164 String multitestOutcome]), | 164 String multitestOutcome]), |
| 165 Function multitestDone) { | 165 Function multitestDone) { |
| 166 // Each new test is a single String value in the Map tests. | 166 // Each new test is a single String value in the Map tests. |
| 167 Map<String, String> tests = new Map<String, String>(); | 167 Map<String, String> tests = new Map<String, String>(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 var split = testDir.split('/'); | 226 var split = testDir.split('/'); |
| 227 var lastComponent = split.removeLast(); | 227 var lastComponent = split.removeLast(); |
| 228 Expect.isTrue(lastComponent == 'src'); | 228 Expect.isTrue(lastComponent == 'src'); |
| 229 String path = '${generatedTestDir.path}/${split.last()}'; | 229 String path = '${generatedTestDir.path}/${split.last()}'; |
| 230 Directory dir = new Directory(path); | 230 Directory dir = new Directory(path); |
| 231 if (!dir.existsSync()) { | 231 if (!dir.existsSync()) { |
| 232 dir.createSync(); | 232 dir.createSync(); |
| 233 } | 233 } |
| 234 return path; | 234 return path; |
| 235 } | 235 } |
| OLD | NEW |