Skip to content

Commit a8e903b

Browse files
authored
Use pkg:build_verify for generated code verification (dart-lang#415)
1 parent fbe31bc commit a8e903b

File tree

2 files changed

+5
-58
lines changed

2 files changed

+5
-58
lines changed

pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ dev_dependencies:
2828
build: '>=0.11.0 <0.13.0'
2929
build_config: '>=0.2.1 <0.4.0'
3030
build_runner: ^0.10.0
31+
build_verify: ^1.0.0
3132
build_version: ^1.0.0
3233
json_serializable: ^1.0.1
3334
source_gen: ^0.9.0
34-
test: ^1.3.0
35+
test: ^1.3.3
3536
test_descriptor: ^1.0.3
3637
test_process: ^1.0.1
3738

test/ensure_build_test.dart

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,8 @@
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'])
92

3+
import 'package:build_verify/build_verify.dart';
104
import 'package:test/test.dart';
115

126
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);
628
}

0 commit comments

Comments
 (0)