| OLD | NEW |
| 1 // Copyright (c) 2012, 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 /** | 5 /** |
| 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub | 6 * Test infrastructure for testing pub. Unlike typical unit tests, most pub |
| 7 * tests are integration tests that stage some stuff on the file system, run | 7 * tests are integration tests that stage some stuff on the file system, run |
| 8 * pub, and then validate the results. This library provides an API to build | 8 * pub, and then validate the results. This library provides an API to build |
| 9 * tests like that. | 9 * tests like that. |
| 10 */ | 10 */ |
| 11 #library('test_pub'); | 11 #library('test_pub'); |
| 12 | 12 |
| 13 #import('dart:io'); | 13 #import('dart:io'); |
| 14 | 14 |
| 15 #import('../../../lib/unittest/unittest.dart'); | 15 #import('../../../lib/unittest/unittest.dart'); |
| 16 #import('../../lib/file_system.dart'); | 16 #import('../../lib/file_system.dart'); |
| 17 | 17 |
| 18 void testOutput(String description, List<String> pubArgs, String expected, | 18 void testOutput(String description, List<String> pubArgs, String expected, |
| 19 [int exitCode = 0]) { | 19 [int exitCode = 0]) { |
| 20 asyncTest(description, 1, () { | 20 asyncTest(description, 1, () { |
| 21 // Find a dart executable we can use to run pub. Uses the one that the | 21 // Find a dart executable we can use to run pub. Uses the one that the |
| 22 // test infrastructure uses. | 22 // test infrastructure uses. |
| 23 final scriptDir = new File(new Options().script).directorySync().path; | 23 final scriptDir = new File(new Options().script).directorySync().path; |
| 24 final platform = new Platform().operatingSystem(); | 24 final platform = Platform.operatingSystem(); |
| 25 final dartBin = joinPaths(scriptDir, | 25 final dartBin = joinPaths(scriptDir, |
| 26 '../../../tools/testing/bin/$platform/dart'); | 26 '../../../tools/testing/bin/$platform/dart'); |
| 27 | 27 |
| 28 // Find the main pub entrypoint. | 28 // Find the main pub entrypoint. |
| 29 final pubPath = joinPaths(scriptDir, '../../pub/pub.dart'); | 29 final pubPath = joinPaths(scriptDir, '../../pub/pub.dart'); |
| 30 | 30 |
| 31 final args = [pubPath]; | 31 final args = [pubPath]; |
| 32 args.addAll(pubArgs); | 32 args.addAll(pubArgs); |
| 33 | 33 |
| 34 final process = new Process.start(dartBin, args); | 34 final process = new Process.start(dartBin, args); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 final message = new StringBuffer(); | 97 final message = new StringBuffer(); |
| 98 message.add('Unexpected output:\n'); | 98 message.add('Unexpected output:\n'); |
| 99 for (var i = expected.length; i < actual.length; i++) { | 99 for (var i = expected.length; i < actual.length; i++) { |
| 100 message.add(actual[i]); | 100 message.add(actual[i]); |
| 101 message.add('\n'); | 101 message.add('\n'); |
| 102 } | 102 } |
| 103 | 103 |
| 104 Expect.fail(message.toString()); | 104 Expect.fail(message.toString()); |
| 105 } | 105 } |
| 106 } | 106 } |
| OLD | NEW |