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 library pub_tests; | 5 library pub_tests; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 | 8 |
| 9 import '../lib/src/sdk.dart' as sdk; |
| 10 |
9 import 'package:pathos/path.dart' as path; | 11 import 'package:pathos/path.dart' as path; |
10 import 'package:scheduled_test/scheduled_process.dart'; | 12 import 'package:scheduled_test/scheduled_process.dart'; |
11 import 'package:scheduled_test/scheduled_test.dart'; | 13 import 'package:scheduled_test/scheduled_test.dart'; |
12 import 'test_pub.dart'; | 14 import 'test_pub.dart'; |
13 | 15 |
14 main() { | 16 main() { |
15 initConfig(); | 17 initConfig(); |
16 | 18 |
17 // This test is a bit funny. | 19 // This test is a bit funny. |
18 // | 20 // |
19 // Pub parses the "version" file that gets generated and shipped with the SDK. | 21 // Pub parses the "version" file that gets generated and shipped with the SDK. |
20 // Most of the pub tests here generate a synthetic SDK directory so that we | 22 // Most of the pub tests here generate a synthetic SDK directory so that we |
21 // can tests against a known SDK state. But we want to make sure that the | 23 // can tests against a known SDK state. But we want to make sure that the |
22 // actual version file that gets created is also one pub can parse. If this | 24 // actual version file that gets created is also one pub can parse. If this |
23 // test fails, it means the version file's format has changed in a way pub | 25 // test fails, it means the version file's format has changed in a way pub |
24 // didn't expect. | 26 // didn't expect. |
25 // | 27 // |
26 // Note that this test expects to be invoked from a Dart executable that is | 28 // Note that this test expects to be invoked from a Dart executable that is |
27 // in the built SDK's "bin" directory. Note also that this invokes pub from | 29 // in the built SDK's "bin" directory. Note also that this invokes pub from |
28 // the built SDK directory, and not the live pub code directly in the repo. | 30 // the built SDK directory, and not the live pub code directly in the repo. |
29 integration('parse the real SDK "version" file', () { | 31 integration('parse the real SDK "version" file', () { |
30 // Get the path to the pub binary in the SDK. | 32 // Get the path to the pub binary in the SDK. |
31 var dartPath = new Options().executable; | 33 var pubPath = path.join(sdk.rootDirectory, 'bin', |
32 var pubPath = path.join(path.dirname(dartPath), "pub"); | 34 Platform.operatingSystem == "windows" ? "pub.bat" : "pub"); |
33 if (Platform.operatingSystem == "windows") pubPath = '$pubPath.bat'; | |
34 | 35 |
35 var pub = new ScheduledProcess.start(pubPath, ['version']); | 36 var pub = new ScheduledProcess.start(pubPath, ['version']); |
36 expect(pub.nextLine(), completion(startsWith("Pub"))); | 37 expect(pub.nextLine(), completion(startsWith("Pub"))); |
37 pub.shouldExit(0); | 38 pub.shouldExit(0); |
38 }); | 39 }); |
39 } | 40 } |
OLD | NEW |