Skip to content

Commit c6f55b8

Browse files
Anna Gringauzejakemac53
andauthored
Support --enable-experiment option in build daemon command (#3183)
* Support --enable-experiment option in build daemon command * update daemon test to build an outline file Co-authored-by: Jake Macdonald <[email protected]>
1 parent 377e334 commit c6f55b8

File tree

4 files changed

+34
-5
lines changed

4 files changed

+34
-5
lines changed

build_runner/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
## 2.1.2-dev
1+
## 2.1.2
2+
3+
- Support `--enable-experiment` option in build daemon.
24

35
## 2.1.1
46

build_runner/lib/src/entrypoint/daemon.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'dart:async';
66
import 'dart:convert';
77
import 'dart:io';
88

9+
import 'package:build/experiments.dart';
910
import 'package:build_daemon/constants.dart';
1011
import 'package:build_daemon/daemon.dart';
1112
import 'package:build_daemon/data/serializers.dart';
@@ -47,8 +48,13 @@ class DaemonCommand extends WatchCommand {
4748

4849
@override
4950
Future<int> run() async {
50-
var workingDirectory = Directory.current.path;
5151
var options = readOptions();
52+
return withEnabledExperiments(
53+
() => _run(options), options.enableExperiments);
54+
}
55+
56+
Future<int> _run(DaemonOptions options) async {
57+
var workingDirectory = Directory.current.path;
5258
var daemon = Daemon(workingDirectory);
5359
var requestedOptions = argResults!.arguments.toSet();
5460
if (!daemon.hasLock) {
@@ -94,7 +100,7 @@ $logEndMarker'''));
94100

95101
// Forward server logs to daemon command STDIO.
96102
var logSub = builder.logs.listen((log) {
97-
if (log.level > Level.INFO) {
103+
if (log.level > Level.INFO || options.verbose) {
98104
var buffer = StringBuffer(log.message);
99105
if (log.error != null) buffer.writeln(log.error);
100106
if (log.stackTrace != null) buffer.writeln(log.stackTrace);

build_runner/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: build_runner
2-
version: 2.1.2-dev
2+
version: 2.1.2
33
description: A build system for Dart code generation and modular compilation.
44
repository: https://github.com/dart-lang/build/tree/master/build_runner
55

build_runner/test/daemon/daemon_test.dart

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,18 @@ main() {
5353
// Don't actually use test package to speed up tests
5454
print('hello');
5555
}'''),
56+
]),
57+
d.dir('lib', [
58+
d.file('message.dart', '''
59+
const message = 'hello world';
60+
'''),
5661
]),
5762
d.dir('web', [
5863
d.file('main.dart', '''
64+
import 'package:a/message.dart';
65+
5966
main() {
60-
print('hello world');
67+
print(message);
6168
}'''),
6269
]),
6370
]).create();
@@ -143,6 +150,20 @@ main() {
143150
]).create();
144151
});
145152

153+
test('supports --enable-experiment option', () async {
154+
await _startDaemon(options: ['--enable-experiment=fake-experiment']);
155+
var client =
156+
await _startClient(options: ['--enable-experiment=fake-experiment'])
157+
..registerBuildTarget(webTarget)
158+
..startBuild();
159+
clients.add(client);
160+
await expectLater(
161+
client.buildResults,
162+
// TODO: Check for specific message about a bad experiment
163+
emitsThrough((BuildResults b) =>
164+
b.results.first.status == BuildStatus.failed));
165+
});
166+
146167
test('does not shut down down on build script change when configured',
147168
() async {
148169
await _startDaemon(options: ['--skip-build-script-check']);

0 commit comments

Comments
 (0)