Migrate to pkg:build_verify for generated file checks (dart-lang/pubspec_parse#24)
Part of https://github.com/kevmoo/build_verify/issues/1
diff --git a/pkgs/pubspec_parse/pubspec.yaml b/pkgs/pubspec_parse/pubspec.yaml
index 2db643d..4178027 100644
--- a/pkgs/pubspec_parse/pubspec.yaml
+++ b/pkgs/pubspec_parse/pubspec.yaml
@@ -17,6 +17,7 @@
dev_dependencies:
build_runner: ^0.10.0
+ build_verify: ^1.0.0
json_serializable: ^1.2.1
path: ^1.5.1
stack_trace: ^1.9.2
diff --git a/pkgs/pubspec_parse/test/ensure_build_test.dart b/pkgs/pubspec_parse/test/ensure_build_test.dart
index 854dd24..ac67c9f 100644
--- a/pkgs/pubspec_parse/test/ensure_build_test.dart
+++ b/pkgs/pubspec_parse/test/ensure_build_test.dart
@@ -4,59 +4,9 @@
@TestOn('vm')
@Tags(const ['presubmit-only'])
-
-import 'dart:convert';
-import 'dart:io';
-
-import 'package:path/path.dart' as p;
+import 'package:build_verify/build_verify.dart';
import 'package:test/test.dart';
void main() {
- // TODO(kevmoo): replace with a common utility
- // https://github.com/dart-lang/build/issues/716
- test('ensure local build succeeds with no changes', () {
- var pkgRoot = _runProc('git', ['rev-parse', '--show-toplevel']);
- var currentDir = Directory.current.resolveSymbolicLinksSync();
-
- if (!p.equals(p.join(pkgRoot), currentDir)) {
- throw new StateError('Expected the git root ($pkgRoot) '
- 'to match the current directory ($currentDir).');
- }
-
- // 1 - get a list of modified `.g.dart` files - should be empty
- expect(_changedGeneratedFiles(), isEmpty);
-
- // 2 - run build - should be no output, since nothing should change
- var result = _runProc('pub',
- ['run', 'build_runner', 'build', '--delete-conflicting-outputs']);
-
- print(result);
- expect(result,
- contains(new RegExp(r'\[INFO\] Succeeded after \S+ with \d+ outputs')));
-
- // 3 - get a list of modified `.g.dart` files - should still be empty
- expect(_changedGeneratedFiles(), isEmpty);
- });
-}
-
-final _whitespace = new RegExp(r'\s');
-
-Set<String> _changedGeneratedFiles() {
- var output = _runProc('git', ['status', '--porcelain']);
-
- return LineSplitter.split(output)
- .map((line) => line.split(_whitespace).last)
- .where((path) => path.endsWith('.dart'))
- .toSet();
-}
-
-String _runProc(String proc, List<String> args) {
- var result = Process.runSync(proc, args);
-
- if (result.exitCode != 0) {
- throw new ProcessException(
- proc, args, result.stderr as String, result.exitCode);
- }
-
- return (result.stdout as String).trim();
+ test('ensure_build', expectBuildClean);
}