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

Side by Side Diff: pkg/code_transformers/lib/tests.dart

Issue 203723006: Fixes how to lookup sdk dir to support tests deeper inside test/ folders. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /// Collection of utilities which are useful for creating unit tests for 5 /// Collection of utilities which are useful for creating unit tests for
6 /// Barback transformers. 6 /// Barback transformers.
7 library code_transformers.tests; 7 library code_transformers.tests;
8 8
9 import 'dart:async' show Future; 9 import 'dart:async' show Future;
10 import 'dart:io' show Platform;
10 11
11 import 'package:barback/barback.dart' show Transformer; 12 import 'package:barback/barback.dart' show Transformer;
13 import 'package:path/path.dart' as path;
12 import 'package:unittest/unittest.dart'; 14 import 'package:unittest/unittest.dart';
13 15
14 import 'src/test_harness.dart'; 16 import 'src/test_harness.dart';
17 import 'src/dart_sdk.dart';
15 18
16 /// Defines a test which invokes [applyTransformers]. 19 /// Defines a test which invokes [applyTransformers].
17 testPhases(String testName, List<List<Transformer>> phases, 20 testPhases(String testName, List<List<Transformer>> phases,
18 Map<String, String> inputs, Map<String, String> results, 21 Map<String, String> inputs, Map<String, String> results,
19 [List<String> messages]) { 22 [List<String> messages]) {
20 test(testName, 23 test(testName,
21 () => applyTransformers(phases, inputs: inputs, results: results, 24 () => applyTransformers(phases, inputs: inputs, results: results,
22 messages: messages)); 25 messages: messages));
23 } 26 }
24 27
25 /// Updates the provided transformers with [inputs] as asset inputs then 28 /// Updates the provided transformers with [inputs] as asset inputs then
26 /// validates that [results] were generated. 29 /// validates that [results] were generated.
27 /// 30 ///
28 /// The keys for inputs and results are 'package_name|lib/file.dart'. 31 /// The keys for inputs and results are 'package_name|lib/file.dart'.
29 /// Only files which are specified in results are validated. 32 /// Only files which are specified in results are validated.
30 /// 33 ///
31 /// If [messages] is non-null then this will validate that only the specified 34 /// If [messages] is non-null then this will validate that only the specified
32 /// messages were generated, ignoring info messages. 35 /// messages were generated, ignoring info messages.
33 Future applyTransformers(List<List<Transformer>> phases, 36 Future applyTransformers(List<List<Transformer>> phases,
34 {Map<String, String> inputs: const {}, 37 {Map<String, String> inputs: const {},
35 Map<String, String> results: const {}, 38 Map<String, String> results: const {},
36 List<String> messages: const []}) { 39 List<String> messages: const []}) {
37 40
38 var helper = new TestHelper(phases, inputs, messages)..run(); 41 var helper = new TestHelper(phases, inputs, messages)..run();
39 return helper.checkAll(results).then((_) => helper.tearDown()); 42 return helper.checkAll(results).then((_) => helper.tearDown());
40 } 43 }
44
45 /// Variant of [dartSdkDirectory] which includes additional cases only
46 /// typically encountered in Dart's testing environment.
47 String get testingDartSdkDirectory {
48 var sdkDir = dartSdkDirectory;
49 if (sdkDir == null) {
50 // If we cannot find the SDK dir, then assume this is being run from Dart's
51 // source directory and this script is the main script.
52 var segments = path.split(path.fromUri(Platform.script));
53 var index = segments.indexOf('pkg');
54 expect(index, greaterThan(0),
55 reason: 'testingDartSdkDirectory is only supported in pkg/ tests');
56 sdkDir = path.joinAll(segments.sublist(0, index)..add('sdk'));
57 }
58 return sdkDir;
59 }
OLDNEW
« no previous file with comments | « pkg/code_transformers/lib/src/dart_sdk.dart ('k') | pkg/smoke/test/codegen/testing_resolver_utils.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698