Skip to content

Commit 07b5911

Browse files
authored
Run end to end tests on macos. (#4229)
* Run end to end tests on macos. * Fix `build_daemon` workspace finding with symlinks.
1 parent de722ae commit 07b5911

File tree

7 files changed

+180
-28
lines changed

7 files changed

+180
-28
lines changed

.github/workflows/dart.yml

Lines changed: 140 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build_daemon/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## 4.0.5-wip
22

3+
- Bug fix: resolve symlinks when identifying workspaces, so symlinks can't
4+
cause the same workspace to be treated as a different workspace.
35
- Bump the min SDK to 3.7.0.
46
- Remove unused dep: `analyzer`.
57
- Add `connectUnchecked` for use in tests.

build_daemon/lib/constants.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ var _username = Platform.environment['USER'] ?? '';
4444
String daemonWorkspace(String workingDirectory) {
4545
final segments = [Directory.systemTemp.path];
4646
if (_username.isNotEmpty) segments.add(_username);
47+
48+
// Canonicalize the working directory so it can be used as a key. First
49+
// `p.canonicalize` which makes it absolute but does not resolve symlinks.
50+
workingDirectory = p.canonicalize(workingDirectory);
51+
// Now resolve symlinks.
52+
try {
53+
workingDirectory = Directory(workingDirectory).resolveSymbolicLinksSync();
54+
} on FileSystemException catch (_) {
55+
// Probably the directory does not exist because this is a test, ignore.
56+
}
57+
4758
final workingDirHash = base64UrlEncode(
4859
md5.convert(workingDirectory.codeUnits).bytes,
4960
);

build_daemon/test/daemon_test.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,29 @@ void main() {
4141
}
4242
});
4343
test('can be stopped', () async {
44-
final workspace = generateV4UUID();
44+
final workspace = randomWorkspace();
4545
testWorkspaces.add(workspace);
4646
final daemon = Daemon(workspace);
4747
await daemon.start(<String>{}, FakeDaemonBuilder(), FakeChangeProvider());
4848
expect(daemon.onDone, completes);
4949
await daemon.stop();
5050
});
5151
test('can run if no other daemon is running', () async {
52-
final workspace = generateV4UUID();
52+
final workspace = randomWorkspace();
5353
final daemon = await _runDaemon(workspace);
5454
testDaemons.add(daemon);
5555
expect(await _statusOf(daemon), 'RUNNING');
5656
});
5757
test('shuts down if no client connects', () async {
58-
final workspace = generateV4UUID();
58+
final workspace = randomWorkspace();
5959
final daemon = await _runDaemon(workspace, timeout: 1);
6060
testDaemons.add(daemon);
6161
expect(await daemon.exitCode, isNotNull);
6262
});
6363
test(
6464
'can not run if another daemon is running in the same workspace',
6565
() async {
66-
final workspace = generateV4UUID();
66+
final workspace = randomWorkspace();
6767
testWorkspaces.add(workspace);
6868
final daemonOne = await _runDaemon(
6969
workspace,
@@ -79,8 +79,8 @@ void main() {
7979
test(
8080
'can run if another daemon is running in a different workspace',
8181
() async {
82-
final workspace1 = generateV4UUID();
83-
final workspace2 = generateV4UUID();
82+
final workspace1 = randomWorkspace();
83+
final workspace2 = randomWorkspace();
8484
testWorkspaces.addAll([workspace1, workspace2]);
8585
final daemonOne = await _runDaemon(workspace1);
8686
expect(await _statusOf(daemonOne), 'RUNNING');
@@ -91,7 +91,7 @@ void main() {
9191
timeout: const Timeout.factor(2),
9292
);
9393
test('can start two daemons at the same time', () async {
94-
final workspace = generateV4UUID();
94+
final workspace = randomWorkspace();
9595
testWorkspaces.add(workspace);
9696
final daemonOne = await _runDaemon(workspace);
9797
expect(await _statusOf(daemonOne), 'RUNNING');
@@ -100,20 +100,20 @@ void main() {
100100
testDaemons.addAll([daemonOne, daemonTwo]);
101101
}, timeout: const Timeout.factor(2));
102102
test('logs the version when running', () async {
103-
final workspace = generateV4UUID();
103+
final workspace = randomWorkspace();
104104
testWorkspaces.add(workspace);
105105
final daemon = await _runDaemon(workspace);
106106
testDaemons.add(daemon);
107107
expect(await _statusOf(daemon), 'RUNNING');
108108
expect(await Daemon(workspace).runningVersion(), currentVersion);
109109
});
110110
test('does not set the current version if not running', () async {
111-
final workspace = generateV4UUID();
111+
final workspace = randomWorkspace();
112112
testWorkspaces.add(workspace);
113113
expect(await Daemon(workspace).runningVersion(), null);
114114
});
115115
test('logs the options when running', () async {
116-
final workspace = generateV4UUID();
116+
final workspace = randomWorkspace();
117117
testWorkspaces.add(workspace);
118118
final daemon = await _runDaemon(workspace);
119119
testDaemons.add(daemon);
@@ -124,12 +124,12 @@ void main() {
124124
);
125125
});
126126
test('does not log the options if not running', () async {
127-
final workspace = generateV4UUID();
127+
final workspace = randomWorkspace();
128128
testWorkspaces.add(workspace);
129129
expect((await Daemon(workspace).currentOptions()).isEmpty, isTrue);
130130
});
131131
test('cleans up after itself', () async {
132-
final workspace = generateV4UUID();
132+
final workspace = randomWorkspace();
133133
testWorkspaces.add(workspace);
134134
final daemon = await _runDaemon(workspace);
135135
// Wait for the daemon to be running before checking the workspace exits.
@@ -141,7 +141,7 @@ void main() {
141141
expect(Directory(daemonWorkspace(workspace)).existsSync(), isFalse);
142142
});
143143
test('daemon stops after file changes stream has error', () async {
144-
final workspace = generateV4UUID();
144+
final workspace = randomWorkspace();
145145
testWorkspaces.add(workspace);
146146
final daemon = await _runDaemon(
147147
workspace,
@@ -152,7 +152,7 @@ void main() {
152152
expect(Directory(daemonWorkspace(workspace)).existsSync(), isFalse);
153153
});
154154
test('daemon stops after file changes stream is closed', () async {
155-
final workspace = generateV4UUID();
155+
final workspace = randomWorkspace();
156156
testWorkspaces.add(workspace);
157157
final daemon = await _runDaemon(
158158
workspace,

build_daemon/test/uuid.dart

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@
66

77
import 'dart:math' show Random;
88

9-
/// A UUID generator.
9+
/// A random workspace path.
1010
///
11-
/// The generated values are 128 bit numbers encoded in a specific string
12-
/// format.
13-
///
14-
/// Generate a version 4 (random) uuid. This is a uuid scheme that only uses
15-
/// random numbers as the source of the generated uuid.
16-
// TODO: replace with a MUCH more simple, random string that matches
17-
// the use case.
18-
String generateV4UUID() {
11+
/// It's an absolute path, so it won't be interpreted differently based on the
12+
/// current working directory.
13+
String randomWorkspace() {
1914
final special = 8 + _random.nextInt(4);
2015

21-
return '${_bitsDigits(16, 4)}${_bitsDigits(16, 4)}-'
16+
return '/${_bitsDigits(16, 4)}${_bitsDigits(16, 4)}-'
2217
'${_bitsDigits(16, 4)}-'
2318
'4${_bitsDigits(12, 3)}-'
2419
'${_printDigits(special, 1)}${_bitsDigits(12, 3)}-'

build_runner/mono_pkg.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@ stages:
1414
- test: -t integration1 --test-randomize-ordering-seed=random
1515
os:
1616
- linux
17+
- macos
1718
- windows
1819
- test: -t integration2 --test-randomize-ordering-seed=random
1920
os:
2021
- linux
22+
- macos
2123
- windows
2224
- test: -t integration3 --test-randomize-ordering-seed=random
2325
os:
2426
- linux
27+
- macos
2528
- windows
2629
- test: -t integration4 --test-randomize-ordering-seed=random
2730
os:
2831
- linux
32+
- macos
2933
- windows
3034
- command: ../tool/leak_check.sh

build_runner/test/integration_tests/daemon_command_test.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ void main() {
8888
// Start client.
8989
var client = await BuildDaemonClient.connectUnchecked(
9090
p.join(tester.tempDirectory.path, 'root_pkg'),
91+
logHandler: (event) => printOnFailure('(0) ${event.message}'),
9192
);
9293
addTearDown(client.close);
9394

@@ -134,6 +135,7 @@ void main() {
134135
// Builds.
135136
client = await BuildDaemonClient.connectUnchecked(
136137
p.join(tester.tempDirectory.path, 'root_pkg'),
138+
logHandler: (event) => printOnFailure('(1) ${event.message}'),
137139
);
138140
addTearDown(client.close);
139141
client.registerBuildTarget(webTarget);
@@ -170,12 +172,14 @@ void main() {
170172
await daemon.expect(readyToConnectLog);
171173
client = await BuildDaemonClient.connectUnchecked(
172174
p.join(tester.tempDirectory.path, 'root_pkg'),
175+
logHandler: (event) => printOnFailure('(2) ${event.message}'),
173176
);
174177
results = StreamQueue(client.buildResults);
175178
addTearDown(client.close);
176179
// Connect to it twice to check both clients are notified later.
177180
final client2 = await BuildDaemonClient.connectUnchecked(
178181
p.join(tester.tempDirectory.path, 'root_pkg'),
182+
logHandler: (event) => printOnFailure('(3) ${event.message}'),
179183
);
180184
final results2 = StreamQueue(client2.buildResults);
181185
addTearDown(client2.close);

0 commit comments

Comments
 (0)