|
1 |
| -// Copyright (c) 2017, 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 |
| -@Tags(const ['presubmit-only']) |
6 |
| - |
7 |
| -import 'dart:convert'; |
8 |
| -import 'dart:io'; |
| 1 | +@Tags(['presubmit-only']) |
9 | 2 |
|
| 3 | +import 'package:build_verify/build_verify.dart'; |
10 | 4 | import 'package:test/test.dart';
|
11 | 5 |
|
12 | 6 | void main() {
|
13 |
| - String pkgRoot; |
14 |
| - try { |
15 |
| - pkgRoot = _runProc('git', ['rev-parse', '--show-toplevel']); |
16 |
| - var currentDir = Directory.current.resolveSymbolicLinksSync(); |
17 |
| - if (pkgRoot != currentDir) { |
18 |
| - throw new StateError("Expected the git root ($pkgRoot) " |
19 |
| - "to match the current directory ($currentDir)."); |
20 |
| - } |
21 |
| - } catch (e) { |
22 |
| - print("Skipping this test – git didn't run correctly"); |
23 |
| - print(e); |
24 |
| - return; |
25 |
| - } |
26 |
| - |
27 |
| - test("ensure local build succeeds with no changes", () { |
28 |
| - // 1 - get a list of modified `.g.dart` files - should be empty |
29 |
| - //expect(_changedGeneratedFiles(), isEmpty); |
30 |
| - |
31 |
| - // 2 - run build - should be no output, since nothing should change |
32 |
| - var result = _runProc('pub', |
33 |
| - ['run', 'build_runner', 'build', '--delete-conflicting-outputs']); |
34 |
| - expect( |
35 |
| - result, contains(new RegExp(r"Succeeded after \S+ with \d+ outputs"))); |
36 |
| - |
37 |
| - // 3 - get a list of modified `.g.dart` files - should still be empty |
38 |
| - expect(_changedGeneratedFiles(), isEmpty); |
39 |
| - }); |
40 |
| -} |
41 |
| - |
42 |
| -final _whitespace = new RegExp(r'\s'); |
43 |
| - |
44 |
| -Set<String> _changedGeneratedFiles() { |
45 |
| - var output = _runProc('git', ['status', '--porcelain']); |
46 |
| - |
47 |
| - return LineSplitter.split(output) |
48 |
| - .map((line) => line.split(_whitespace).last) |
49 |
| - .where((path) => path.endsWith('.g.dart')) |
50 |
| - .toSet(); |
51 |
| -} |
52 |
| - |
53 |
| -String _runProc(String proc, List<String> args) { |
54 |
| - var result = Process.runSync(proc, args); |
55 |
| - |
56 |
| - if (result.exitCode != 0) { |
57 |
| - throw new ProcessException( |
58 |
| - proc, args, result.stderr as String, result.exitCode); |
59 |
| - } |
60 |
| - |
61 |
| - return (result.stdout as String).trim(); |
| 7 | + test('ensure_build', expectBuildClean); |
62 | 8 | }
|
0 commit comments