Skip to content

Test for build failure if an unexpected file exists in the target directory #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions webdev/test/e2e_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ void main() {
await d.file('pubspec.lock', isNotEmpty).validate(exampleDirectory);
});

test('build should fail if targetting an existing directory', () async {
await d.file('simple thing', 'throw-away').create();

var args = ['build', '-o', 'web:${d.sandbox}'];

var process = await runWebDev(args, workingDirectory: exampleDirectory);

// NOTE: We'd like this to be more useful
// See https://github.com/dart-lang/build/issues/1283

await expectLater(
process.stdout,
emitsThrough(
'[WARNING] Skipped creation of the merged output directory.'));
await expectLater(process.stderr,
emitsThrough('Failed to create merged output directories.'));

await process.shouldExit(1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that we will be breaking this when we implement dart-lang/build#1283

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. We can update our min requirement on build_runner then...

});

group('should build with valid configuration', () {
for (var withDDC in [true, false]) {
test(withDDC ? 'DDC' : 'dart2js', () async {
Expand All @@ -50,10 +70,6 @@ void main() {
var process = await runWebDev(args, workingDirectory: exampleDirectory);

var expectedItems = <Object>['[INFO] Succeeded'];
if (!withDDC) {
expectedItems.add(anyOf(
contains('with 0 outputs'), contains('Running dart2js with')));
}

await checkProcessStdout(process, expectedItems);
await process.shouldExit(0);
Expand Down
8 changes: 4 additions & 4 deletions webdev/test/integration_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ name: sample
var process = await runWebDev([command], workingDirectory: d.sandbox);

await checkProcessStdout(process, [
r'''webdev could not run for this project.
You must have a dependency on `build_runner` in `pubspec.yaml`.'''
'webdev could not run for this project.',
'You must have a dependency on `build_runner` in `pubspec.yaml`.'
]);
await process.shouldExit(78);
});
Expand All @@ -63,8 +63,8 @@ name: sample
var process = await runWebDev(['serve'], workingDirectory: d.sandbox);

await checkProcessStdout(process, [
r'''webdev could not run for this project.
You must have a dependency on `build_web_compilers` in `pubspec.yaml`.'''
'webdev could not run for this project.',
'You must have a dependency on `build_web_compilers` in `pubspec.yaml`.'
]);
await process.shouldExit(78);
});
Expand Down
4 changes: 2 additions & 2 deletions webdev/test/test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ Future<TestProcess> runWebDev(List<String> args, {String workingDirectory}) {
}

Future checkProcessStdout(TestProcess process, List items) async {
var output = await process.stdoutStream().join('\n');
for (var item in items) {
if (item is! Matcher) {
item = contains(item);
}
expect(output, item);

await expectLater(process.stdout, emitsThrough(item));
}
}