Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: test/test_pub.dart

Issue 1145993003: Fix asset and SDK path detection. (Closed) Base URL: git@github.com:dart-lang/pub_test@master
Patch Set: Code review changes Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/real_version_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 /// Test infrastructure for testing pub. 5 /// Test infrastructure for testing pub.
6 /// 6 ///
7 /// Unlike typical unit tests, most pub tests are integration tests that stage 7 /// Unlike typical unit tests, most pub tests are integration tests that stage
8 /// some stuff on the file system, run pub, and then validate the results. This 8 /// some stuff on the file system, run pub, and then validate the results. This
9 /// library provides an API to build tests like that. 9 /// library provides an API to build tests like that.
10 library test_pub; 10 library test_pub;
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 _sandboxDir = createSystemTempDir(); 366 _sandboxDir = createSystemTempDir();
367 d.defaultRoot = sandboxDir; 367 d.defaultRoot = sandboxDir;
368 currentSchedule.onComplete.schedule(() => deleteEntry(_sandboxDir), 368 currentSchedule.onComplete.schedule(() => deleteEntry(_sandboxDir),
369 'deleting the sandbox directory'); 369 'deleting the sandbox directory');
370 370
371 // Schedule the test. 371 // Schedule the test.
372 body(); 372 body();
373 }); 373 });
374 } 374 }
375 375
376 /// Get the path to the root "pub/test" directory containing the pub
377 /// tests.
378 String get testDirectory =>
379 p.absolute(p.dirname(libraryPath('test_pub')));
380
381 /// Schedules renaming (moving) the directory at [from] to [to], both of which 376 /// Schedules renaming (moving) the directory at [from] to [to], both of which
382 /// are assumed to be relative to [sandboxDir]. 377 /// are assumed to be relative to [sandboxDir].
383 void scheduleRename(String from, String to) { 378 void scheduleRename(String from, String to) {
384 schedule( 379 schedule(
385 () => renameDir( 380 () => renameDir(
386 p.join(sandboxDir, from), 381 p.join(sandboxDir, from),
387 p.join(sandboxDir, to)), 382 p.join(sandboxDir, to)),
388 'renaming $from to $to'); 383 'renaming $from to $to');
389 } 384 }
390 385
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 "homepage": "http://pub.dartlang.org", 845 "homepage": "http://pub.dartlang.org",
851 "description": "A package, I guess." 846 "description": "A package, I guess."
852 }; 847 };
853 848
854 if (dependencies != null) package["dependencies"] = dependencies; 849 if (dependencies != null) package["dependencies"] = dependencies;
855 850
856 return package; 851 return package;
857 } 852 }
858 853
859 /// Resolves [target] relative to the path to pub's `test/asset` directory. 854 /// Resolves [target] relative to the path to pub's `test/asset` directory.
860 String testAssetPath(String target) => 855 String testAssetPath(String target) => p.join(pubRoot, 'test', 'asset', target);
861 p.join(p.dirname(libraryPath('test_pub')), 'asset', target);
862 856
863 /// Returns a Map in the format used by the pub.dartlang.org API to represent a 857 /// Returns a Map in the format used by the pub.dartlang.org API to represent a
864 /// package version. 858 /// package version.
865 /// 859 ///
866 /// [pubspec] is the parsed pubspec of the package version. If [full] is true, 860 /// [pubspec] is the parsed pubspec of the package version. If [full] is true,
867 /// this returns the complete map, including metadata that's only included when 861 /// this returns the complete map, including metadata that's only included when
868 /// requesting the package version directly. 862 /// requesting the package version directly.
869 Map packageVersionApiMap(Map pubspec, {bool full: false}) { 863 Map packageVersionApiMap(Map pubspec, {bool full: false}) {
870 var name = pubspec['name']; 864 var name = pubspec['name'];
871 var version = pubspec['version']; 865 var version = pubspec['version'];
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 _lastMatcher.matches(item.last, matchState); 1014 _lastMatcher.matches(item.last, matchState);
1021 } 1015 }
1022 1016
1023 Description describe(Description description) { 1017 Description describe(Description description) {
1024 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]); 1018 return description.addAll("(", ", ", ")", [_firstMatcher, _lastMatcher]);
1025 } 1019 }
1026 } 1020 }
1027 1021
1028 /// A [StreamMatcher] that matches multiple lines of output. 1022 /// A [StreamMatcher] that matches multiple lines of output.
1029 StreamMatcher emitsLines(String output) => inOrder(output.split("\n")); 1023 StreamMatcher emitsLines(String output) => inOrder(output.split("\n"));
OLDNEW
« no previous file with comments | « test/real_version_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698