OLD | NEW |
| (Empty) |
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 | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 library docgen.test.util; | |
6 | |
7 import 'dart:convert'; | |
8 import 'dart:io'; | |
9 import 'package:path/path.dart' as p; | |
10 import 'package:scheduled_test/descriptor.dart' as d; | |
11 import 'package:scheduled_test/scheduled_test.dart'; | |
12 | |
13 void scheduleTempDir() { | |
14 var tempDir; | |
15 schedule(() { | |
16 return Directory.systemTemp | |
17 .createTemp('docgen_test-') | |
18 .then((dir) { | |
19 tempDir = dir; | |
20 d.defaultRoot = tempDir.path; | |
21 }); | |
22 }); | |
23 | |
24 currentSchedule.onComplete.schedule(() { | |
25 d.defaultRoot = null; | |
26 return tempDir.delete(recursive: true); | |
27 }); | |
28 } | |
29 | |
30 String getMultiLibraryCodePath() { | |
31 var currentScript = p.fromUri(Platform.script); | |
32 var codeDir = p.join(p.dirname(currentScript), 'multi_library_code'); | |
33 | |
34 assert(FileSystemEntity.isDirectorySync(codeDir)); | |
35 | |
36 return codeDir; | |
37 } | |
38 | |
39 final Matcher hasSortedLines = predicate((String input) { | |
40 var lines = new LineSplitter().convert(input); | |
41 | |
42 var sortedLines = new List.from(lines)..sort(); | |
43 | |
44 var orderedMatcher = orderedEquals(sortedLines); | |
45 return orderedMatcher.matches(lines, {}); | |
46 }, 'String has sorted lines'); | |
47 | |
48 final Matcher isJsonMap = predicate((input) { | |
49 try { | |
50 return JSON.decode(input) is Map; | |
51 } catch (e) { | |
52 return false; | |
53 } | |
54 }, 'Output is JSON encoded Map'); | |
OLD | NEW |