Skip to content

Commit 1ecd76d

Browse files
committed
get basic windows support working
1 parent 182f1f5 commit 1ecd76d

File tree

6 files changed

+57
-43
lines changed

6 files changed

+57
-43
lines changed

lib/src/generate/watch_impl.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ class WatchImpl {
190190

191191
/// Checks if we should skip a watch event for this [id].
192192
bool _shouldSkipInput(AssetId id, ChangeType type) {
193-
if (id.path.startsWith('.build')) return true;
193+
if (id.path.contains('.build/')) return true;
194194
var node = _assetGraph.get(id);
195195
return node is GeneratedAssetNode && type != ChangeType.REMOVE;
196196
}

lib/src/package_graph/package_graph.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,13 @@ class PackageGraph {
5454
packagesFile.readAsLinesSync().skip(1).forEach((line) {
5555
var firstColon = line.indexOf(':');
5656
var name = line.substring(0, firstColon);
57-
assert(line.endsWith('lib${Platform.pathSeparator}'));
57+
assert(line.endsWith('lib/'));
5858
// Start after package_name:, and strip out trailing `lib` dir.
5959
var uriString = line.substring(firstColon + 1, line.length - 4);
60+
// Strip the trailing slash, if present.
61+
if (uriString.endsWith('/')) {
62+
uriString = uriString.substring(0, uriString.length - 1);
63+
}
6064
var uri;
6165
try {
6266
uri = Uri.parse(uriString);

test/asset/file_based_test.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,32 @@
44
@TestOn('vm')
55
import 'dart:io';
66

7+
import 'package:path/path.dart' as path;
78
import 'package:test/test.dart';
89

910
import 'package:build/build.dart';
1011

1112
import '../common/common.dart';
1213

13-
final packageGraph = new PackageGraph.forPath('test/fixtures/basic_pkg');
14+
final packageGraph =
15+
new PackageGraph.forPath('test/fixtures/basic_pkg');
16+
final newLine = Platform.isWindows ? '\r\n' : '\n';
1417

1518
main() {
1619
group('FileBasedAssetReader', () {
1720
final reader = new FileBasedAssetReader(packageGraph, ignoredDirs: ['pkg']);
1821

1922
test('can read any application package files', () async {
2023
expect(await reader.readAsString(makeAssetId('basic_pkg|hello.txt')),
21-
'world\n');
24+
'world$newLine');
2225
expect(await reader.readAsString(makeAssetId('basic_pkg|lib/hello.txt')),
23-
'world\n');
26+
'world$newLine');
2427
expect(await reader.readAsString(makeAssetId('basic_pkg|web/hello.txt')),
25-
'world\n');
28+
'world$newLine');
2629
});
2730

2831
test('can read package dependency files in the lib dir', () async {
29-
expect(await reader.readAsString(makeAssetId('a|lib/a.txt')), 'A\n');
32+
expect(await reader.readAsString(makeAssetId('a|lib/a.txt')), 'A$newLine');
3033
});
3134

3235
test('can check for existence of any application package files', () async {
@@ -101,7 +104,7 @@ main() {
101104
var asset = makeAsset('basic_pkg|test_file.txt', 'test');
102105
await writer.writeAsString(asset);
103106
var id = asset.id;
104-
var file = new File('test/fixtures/${id.package}/${id.path}');
107+
var file = new File(path.join('test', 'fixtures', id.package, id.path));
105108
expect(await file.exists(), isTrue);
106109
expect(await file.readAsString(), 'test');
107110

test/generate/serve_test.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import 'dart:async';
55

66
import 'package:logging/logging.dart';
7+
import 'package:path/path.dart' as path;
78
import 'package:test/test.dart';
89

910
import 'package:build/build.dart';
@@ -44,8 +45,8 @@ main() {
4445
checkOutputs({'a|web/a.txt.copy': 'a'}, result, writer.assets);
4546

4647
await writer.writeAsString(makeAsset('a|web/a.txt', 'b'));
47-
FakeWatcher
48-
.notifyWatchers(new WatchEvent(ChangeType.MODIFY, 'a/web/a.txt'));
48+
FakeWatcher.notifyWatchers(
49+
new WatchEvent(ChangeType.MODIFY, path.join('a', 'web', 'a.txt')));
4950

5051
result = await nextResult(results);
5152
checkOutputs({'a|web/a.txt.copy': 'b',}, result, writer.assets);
@@ -82,8 +83,8 @@ main() {
8283
/// Make an edit to force another build, and we should block again.
8384
copyBuilder.blockUntil = buildBlocker2.future;
8485
await writer.writeAsString(makeAsset('a|web/a.txt', 'b'));
85-
FakeWatcher
86-
.notifyWatchers(new WatchEvent(ChangeType.MODIFY, 'a/web/a.txt'));
86+
FakeWatcher.notifyWatchers(
87+
new WatchEvent(ChangeType.MODIFY, path.join('a', 'web', 'a.txt')));
8788
// Give the build enough time to get started.
8889
await wait(500);
8990
var done = new Completer();

test/generate/watch_test.dart

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'dart:async';
55
import 'dart:convert';
66

77
import 'package:logging/logging.dart';
8+
import 'package:path/path.dart' as path;
89
import 'package:test/test.dart';
910
import 'package:watcher/watcher.dart';
1011

@@ -40,8 +41,8 @@ main() {
4041
checkOutputs({'a|web/a.txt.copy': 'a',}, result, writer.assets);
4142

4243
await writer.writeAsString(makeAsset('a|web/a.txt', 'b'));
43-
FakeWatcher
44-
.notifyWatchers(new WatchEvent(ChangeType.MODIFY, 'a/web/a.txt'));
44+
FakeWatcher.notifyWatchers(
45+
new WatchEvent(ChangeType.MODIFY, path.join('a', 'web', 'a.txt')));
4546

4647
result = await nextResult(results);
4748
checkOutputs({'a|web/a.txt.copy': 'b',}, result, writer.assets);
@@ -57,8 +58,8 @@ main() {
5758
checkOutputs({'a|web/a.txt.copy': 'a',}, result, writer.assets);
5859

5960
await writer.writeAsString(makeAsset('a|web/b.txt', 'b'));
60-
FakeWatcher
61-
.notifyWatchers(new WatchEvent(ChangeType.ADD, 'a/web/b.txt'));
61+
FakeWatcher.notifyWatchers(
62+
new WatchEvent(ChangeType.ADD, path.join('a', 'web', 'b.txt')));
6263

6364
result = await nextResult(results);
6465
checkOutputs({'a|web/b.txt.copy': 'b',}, result, writer.assets);
@@ -78,8 +79,8 @@ main() {
7879
result, writer.assets);
7980

8081
await writer.delete(makeAssetId('a|web/a.txt'));
81-
FakeWatcher
82-
.notifyWatchers(new WatchEvent(ChangeType.REMOVE, 'a/web/a.txt'));
82+
FakeWatcher.notifyWatchers(
83+
new WatchEvent(ChangeType.REMOVE, path.join('a', 'web', 'a.txt')));
8384

8485
result = await nextResult(results);
8586

@@ -104,11 +105,11 @@ main() {
104105
result, writer.assets);
105106

106107
await writer.writeAsString(makeAsset('a|web/c.txt', 'c'));
107-
FakeWatcher
108-
.notifyWatchers(new WatchEvent(ChangeType.ADD, 'a/web/c.txt'));
108+
FakeWatcher.notifyWatchers(
109+
new WatchEvent(ChangeType.ADD, path.join('a', 'web', 'c.txt')));
109110
await writer.delete(makeAssetId('a|web/a.txt'));
110-
FakeWatcher
111-
.notifyWatchers(new WatchEvent(ChangeType.REMOVE, 'a/web/a.txt'));
111+
FakeWatcher.notifyWatchers(
112+
new WatchEvent(ChangeType.REMOVE, path.join('a', 'web', 'a.txt')));
112113

113114
result = await nextResult(results);
114115
checkOutputs({'a|web/c.txt.copy': 'c'}, result, writer.assets);
@@ -141,8 +142,8 @@ main() {
141142
await writer.writeAsString(makeAsset('test|lib/test.dart', ''),
142143
lastModified: new DateTime.now().add(new Duration(days: 1)));
143144
await writer.writeAsString(makeAsset('a|web/a.txt', 'b'));
144-
FakeWatcher
145-
.notifyWatchers(new WatchEvent(ChangeType.MODIFY, 'a/web/a.txt'));
145+
FakeWatcher.notifyWatchers(
146+
new WatchEvent(ChangeType.MODIFY, path.join('a', 'web', 'a.txt')));
146147

147148
result = await nextResult(results);
148149
expect(result.status, BuildStatus.Failure);
@@ -165,8 +166,8 @@ main() {
165166
result, writer.assets);
166167

167168
await writer.writeAsString(makeAsset('a|web/a.txt', 'b'));
168-
FakeWatcher
169-
.notifyWatchers(new WatchEvent(ChangeType.MODIFY, 'a/web/a.txt'));
169+
FakeWatcher.notifyWatchers(
170+
new WatchEvent(ChangeType.MODIFY, path.join('a', 'web', 'a.txt')));
170171

171172
result = await nextResult(results);
172173
checkOutputs({'a|web/a.txt.copy': 'b', 'a|web/a.txt.copy.copy': 'b'},
@@ -188,8 +189,8 @@ main() {
188189
result, writer.assets);
189190

190191
await writer.writeAsString(makeAsset('a|web/b.txt', 'b'));
191-
FakeWatcher
192-
.notifyWatchers(new WatchEvent(ChangeType.ADD, 'a/web/b.txt'));
192+
FakeWatcher.notifyWatchers(
193+
new WatchEvent(ChangeType.ADD, path.join('a', 'web', 'b.txt')));
193194

194195
result = await nextResult(results);
195196
checkOutputs({'a|web/b.txt.copy': 'b', 'a|web/b.txt.copy.copy': 'b'},
@@ -219,8 +220,8 @@ main() {
219220
}, result, writer.assets);
220221

221222
await writer.delete(makeAssetId('a|web/a.txt'));
222-
FakeWatcher
223-
.notifyWatchers(new WatchEvent(ChangeType.REMOVE, 'a/web/a.txt'));
223+
FakeWatcher.notifyWatchers(
224+
new WatchEvent(ChangeType.REMOVE, path.join('a', 'web', 'a.txt')));
224225

225226
result = await nextResult(results);
226227
// Shouldn't rebuild anything, no outputs.
@@ -249,8 +250,8 @@ main() {
249250
result, writer.assets);
250251

251252
await writer.delete(makeAssetId('a|web/a.txt.copy'));
252-
FakeWatcher.notifyWatchers(
253-
new WatchEvent(ChangeType.REMOVE, 'a/web/a.txt.copy'));
253+
FakeWatcher.notifyWatchers(new WatchEvent(
254+
ChangeType.REMOVE, path.join('a', 'web', 'a.txt.copy')));
254255

255256
result = await nextResult(results);
256257
// Should rebuild the generated asset and its outputs.
@@ -275,8 +276,8 @@ main() {
275276
checkOutputs({'a|web/a.txt.copy': 'b'}, result, writer.assets);
276277

277278
await writer.writeAsString(makeAsset('a|web/b.txt', 'c'));
278-
FakeWatcher
279-
.notifyWatchers(new WatchEvent(ChangeType.MODIFY, 'a/web/b.txt'));
279+
FakeWatcher.notifyWatchers(
280+
new WatchEvent(ChangeType.MODIFY, path.join('a', 'web', 'b.txt')));
280281

281282
result = await nextResult(results);
282283
checkOutputs({'a|web/a.txt.copy': 'c'}, result, writer.assets);
@@ -303,8 +304,8 @@ main() {
303304
result, writer.assets);
304305

305306
await writer.writeAsString(makeAsset('a|web/b.txt', 'c'));
306-
FakeWatcher
307-
.notifyWatchers(new WatchEvent(ChangeType.MODIFY, 'a/web/b.txt'));
307+
FakeWatcher.notifyWatchers(
308+
new WatchEvent(ChangeType.MODIFY, path.join('a', 'web', 'b.txt')));
308309

309310
result = await nextResult(results);
310311
checkOutputs({'a|web/a.txt.copy.copy': 'c'}, result, writer.assets);

test/package_graph/package_graph_test.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44
@TestOn('vm')
5+
import 'package:path/path.dart' as path;
56
import 'package:test/test.dart';
67

78
import 'package:build/build.dart';
@@ -44,17 +45,17 @@ main() {
4445

4546
test('pub dependency', () {
4647
expectPkg(graph['a'], 'a', '2.0.0', PackageDependencyType.Pub,
47-
'$basicPkgPath/pkg/a/', [graph['b'], graph['c']]);
48+
'$basicPkgPath/pkg/a', [graph['b'], graph['c']]);
4849
});
4950

5051
test('git dependency', () {
5152
expectPkg(graph['b'], 'b', '3.0.0', PackageDependencyType.Github,
52-
'$basicPkgPath/pkg/b/', [graph['c']]);
53+
'$basicPkgPath/pkg/b', [graph['c']]);
5354
});
5455

5556
test('path dependency', () {
5657
expectPkg(graph['c'], 'c', '4.0.0', PackageDependencyType.Path,
57-
'$basicPkgPath/pkg/c/', [graph['basic_pkg']]);
58+
'$basicPkgPath/pkg/c', [graph['basic_pkg']]);
5859
});
5960
});
6061

@@ -87,10 +88,10 @@ main() {
8788

8889
// Package `c` does not appear because this is not the root package.
8990
expectPkg(graph['a'], 'a', '2.0.0', PackageDependencyType.Pub,
90-
'$withDevDepsPkgPath/pkg/a/', []);
91+
'$withDevDepsPkgPath/pkg/a', []);
9192

9293
expectPkg(graph['b'], 'b', '3.0.0', PackageDependencyType.Pub,
93-
'$withDevDepsPkgPath/pkg/b/', []);
94+
'$withDevDepsPkgPath/pkg/b', []);
9495

9596
expect(graph['c'], isNull);
9697
});
@@ -110,11 +111,15 @@ main() {
110111

111112
test('missing pubspec throws on create', () {
112113
expect(
113-
() => new PackageGraph.forPath('test/fixtures/no_pubspec'), throws);
114+
() => new PackageGraph.forPath(
115+
path.join('test', 'fixtures', 'no_pubspec')),
116+
throws);
114117
});
115118

116119
test('missing .packages file throws on create', () {
117-
expect(() => new PackageGraph.forPath('test/fixtures/no_packages_file'),
120+
expect(
121+
() => new PackageGraph.forPath(
122+
path.join('test', 'fixtures', 'no_packages_file')),
118123
throws);
119124
});
120125
});

0 commit comments

Comments
 (0)