Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
|
Brian Wilkerson
2017/08/02 13:52:47
2017
devoncarew
2017/08/02 15:04:48
Done.
| |
| 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.=> defineTests(); | |
| 4 | |
| 5 /// This tests the benchmarks in benchmark/benchmark.test, and ensures that our | |
| 6 /// benchmarks can run. | |
| 7 | |
| 8 import 'dart:convert'; | |
| 9 import 'dart:io'; | |
| 10 | |
| 11 import 'package:path/path.dart' as path; | |
| 12 import 'package:test/test.dart'; | |
| 13 | |
| 14 void main() => defineTests(); | |
| 15 | |
| 16 void defineTests() { | |
| 17 group('benchmarks', () { | |
| 18 final List<String> benchmarks = _listBenchmarks(); | |
| 19 | |
| 20 test('can list', () { | |
| 21 expect(benchmarks, isNotEmpty); | |
| 22 }); | |
| 23 | |
| 24 for (String benchmarkId in benchmarks) { | |
| 25 test(benchmarkId, () { | |
| 26 ProcessResult r = Process.runSync( | |
| 27 Platform.resolvedExecutable, | |
| 28 [ | |
| 29 path.join('benchmark', 'benchmarks.dart'), | |
| 30 'run', | |
| 31 '--repeat=1', | |
| 32 '--quick', | |
| 33 benchmarkId | |
| 34 ], | |
| 35 workingDirectory: _serverSourcePath, | |
| 36 ); | |
| 37 expect(r.exitCode, 0, | |
| 38 reason: 'exit: ${r.exitCode}\n${r.stdout}\n${r.stderr}'); | |
| 39 }); | |
| 40 } | |
| 41 }); | |
| 42 } | |
| 43 | |
| 44 List<String> _listBenchmarks() { | |
| 45 ProcessResult result = Process.runSync( | |
| 46 Platform.resolvedExecutable, | |
| 47 [path.join('benchmark', 'benchmarks.dart'), 'list', '--machine'], | |
| 48 workingDirectory: _serverSourcePath, | |
| 49 ); | |
| 50 Map m = JSON.decode(result.stdout); | |
| 51 List benchmarks = m['benchmarks']; | |
| 52 return benchmarks.map((b) => b['id']).toList(); | |
| 53 } | |
| 54 | |
| 55 String get _serverSourcePath { | |
| 56 String script = Platform.script.toFilePath(windows: Platform.isWindows); | |
| 57 String pkgPath = path.normalize(path.join(path.dirname(script), '..', '..')); | |
| 58 return path.join(pkgPath, 'analysis_server'); | |
| 59 } | |
| OLD | NEW |