Skip to content
This repository was archived by the owner on Dec 9, 2023. It is now read-only.

Commit cf3115c

Browse files
authored
General cleanup (#25)
* Re-enable Windows tests * Update analysis options * Remove deprecated member access
1 parent 0fd4b32 commit cf3115c

File tree

8 files changed

+49
-38
lines changed

8 files changed

+49
-38
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#### 3.0.1
2+
3+
* General cleanup
4+
15
#### 3.0.0
26

37
* Cleanup getExecutablePath() to better respect the platform

analysis_options.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
analyzer:
22
language:
3-
enableStrictCallChecks: true
43
enableSuperMixins: true
5-
strong-mode: true
4+
strong-mode:
5+
implicit-dynamic: false
66
errors:
7+
missing_required_param: warning
8+
missing_return: warning
79
# Allow having TODOs in the code
810
todo: ignore
911

@@ -60,7 +62,7 @@ linter:
6062
- type_annotate_public_apis
6163
- type_init_formals
6264
- unawaited_futures
63-
- unnecessary_brace_in_string_interp
65+
- unnecessary_brace_in_string_interps
6466
- unnecessary_getters_setters
6567

6668
# === pub rules ===

lib/src/interface/common.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import 'package:file/file.dart';
66
import 'package:file/local.dart';
7-
import 'package:path/path.dart' show Context, Style;
7+
import 'package:path/path.dart' show Context;
88
import 'package:platform/platform.dart';
99

1010
const Map<String, String> _osToPathStyle = const <String, String>{

lib/src/record_replay/replay_process_manager.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ReplayProcessManager implements ProcessManager {
6161
/// start listening.
6262
static Future<ReplayProcessManager> create(
6363
Directory location, {
64-
Duration streamDelay: Duration.ZERO,
64+
Duration streamDelay: Duration.zero,
6565
}) async {
6666
assert(streamDelay != null);
6767

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: process
2-
version: 3.0.0
2+
version: 3.0.1
33
authors:
44
- Todd Volkert <[email protected]>
55
- Michael Goderbauer <[email protected]>

test/record_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class _Recording {
143143
_Recording(this.dir);
144144

145145
List<Map<String, dynamic>> get manifest {
146-
return JSON.decoder.convert(_getFileContent('MANIFEST.txt', UTF8));
146+
return json.decoder.convert(_getFileContent('MANIFEST.txt', utf8));
147147
}
148148

149149
dynamic stdoutForEntryAt(int index) =>

test/src/interface/common_test.dart

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import 'package:file/file.dart';
66
import 'package:file/memory.dart';
7-
import 'package:path/path.dart' as p;
87
import 'package:platform/platform.dart';
98
import 'package:process/src/interface/common.dart';
109
import 'package:test/test.dart';
@@ -14,13 +13,15 @@ void main() {
1413
FileSystem fs;
1514
Directory workingDir, dir1, dir2, dir3;
1615

17-
setUp(() {
18-
fs = new MemoryFileSystem();
19-
workingDir = fs.systemTempDirectory.createTempSync('work_dir_');
20-
dir1 = fs.systemTempDirectory.createTempSync('dir1_');
21-
dir2 = fs.systemTempDirectory.createTempSync('dir2_');
22-
dir3 = fs.systemTempDirectory.createTempSync('dir3_');
23-
});
16+
void initialize(FileSystemStyle style) {
17+
setUp(() {
18+
fs = new MemoryFileSystem(style: style);
19+
workingDir = fs.systemTempDirectory.createTempSync('work_dir_');
20+
dir1 = fs.systemTempDirectory.createTempSync('dir1_');
21+
dir2 = fs.systemTempDirectory.createTempSync('dir2_');
22+
dir3 = fs.systemTempDirectory.createTempSync('dir3_');
23+
});
24+
}
2425

2526
tearDown(() {
2627
<Directory>[workingDir, dir1, dir2, dir3]
@@ -30,6 +31,8 @@ void main() {
3031
group('on windows', () {
3132
Platform platform;
3233

34+
initialize(FileSystemStyle.windows);
35+
3336
setUp(() {
3437
platform = new FakePlatform(
3538
operatingSystem: 'windows',
@@ -41,7 +44,7 @@ void main() {
4144
});
4245

4346
test('absolute', () {
44-
String command = p.join(dir3.path, 'bla.exe');
47+
String command = fs.path.join(dir3.path, 'bla.exe');
4548
String expectedPath = command;
4649
fs.file(command).createSync();
4750

@@ -53,7 +56,7 @@ void main() {
5356
);
5457
_expectSamePath(executablePath, expectedPath);
5558

56-
command = p.withoutExtension(command);
59+
command = fs.path.withoutExtension(command);
5760
executablePath = getExecutablePath(
5861
command,
5962
workingDir.path,
@@ -65,7 +68,7 @@ void main() {
6568

6669
test('in path', () {
6770
String command = 'bla.exe';
68-
String expectedPath = p.join(dir2.path, command);
71+
String expectedPath = fs.path.join(dir2.path, command);
6972
fs.file(expectedPath).createSync();
7073

7174
String executablePath = getExecutablePath(
@@ -76,7 +79,7 @@ void main() {
7679
);
7780
_expectSamePath(executablePath, expectedPath);
7881

79-
command = p.withoutExtension(command);
82+
command = fs.path.withoutExtension(command);
8083
executablePath = getExecutablePath(
8184
command,
8285
workingDir.path,
@@ -88,8 +91,8 @@ void main() {
8891

8992
test('in path multiple times', () {
9093
String command = 'bla.exe';
91-
String expectedPath = p.join(dir1.path, command);
92-
String wrongPath = p.join(dir2.path, command);
94+
String expectedPath = fs.path.join(dir1.path, command);
95+
String wrongPath = fs.path.join(dir2.path, command);
9396
fs.file(expectedPath).createSync();
9497
fs.file(wrongPath).createSync();
9598

@@ -101,7 +104,7 @@ void main() {
101104
);
102105
_expectSamePath(executablePath, expectedPath);
103106

104-
command = p.withoutExtension(command);
107+
command = fs.path.withoutExtension(command);
105108
executablePath = getExecutablePath(
106109
command,
107110
workingDir.path,
@@ -112,8 +115,8 @@ void main() {
112115
});
113116

114117
test('in subdir of work dir', () {
115-
String command = p.join('.', 'foo', 'bla.exe');
116-
String expectedPath = p.join(workingDir.path, command);
118+
String command = fs.path.join('.', 'foo', 'bla.exe');
119+
String expectedPath = fs.path.join(workingDir.path, command);
117120
fs.file(expectedPath).createSync(recursive: true);
118121

119122
String executablePath = getExecutablePath(
@@ -124,7 +127,7 @@ void main() {
124127
);
125128
_expectSamePath(executablePath, expectedPath);
126129

127-
command = p.withoutExtension(command);
130+
command = fs.path.withoutExtension(command);
128131
executablePath = getExecutablePath(
129132
command,
130133
workingDir.path,
@@ -135,9 +138,9 @@ void main() {
135138
});
136139

137140
test('in work dir', () {
138-
String command = p.join('.', 'bla.exe');
139-
String expectedPath = p.join(workingDir.path, command);
140-
String wrongPath = p.join(dir2.path, command);
141+
String command = fs.path.join('.', 'bla.exe');
142+
String expectedPath = fs.path.join(workingDir.path, command);
143+
String wrongPath = fs.path.join(dir2.path, command);
141144
fs.file(expectedPath).createSync();
142145
fs.file(wrongPath).createSync();
143146

@@ -149,7 +152,7 @@ void main() {
149152
);
150153
_expectSamePath(executablePath, expectedPath);
151154

152-
command = p.withoutExtension(command);
155+
command = fs.path.withoutExtension(command);
153156
executablePath = getExecutablePath(
154157
command,
155158
workingDir.path,
@@ -161,9 +164,9 @@ void main() {
161164

162165
test('with multiple extensions', () {
163166
String command = 'foo';
164-
String expectedPath = p.join(dir1.path, '$command.exe');
165-
String wrongPath1 = p.join(dir1.path, '$command.bat');
166-
String wrongPath2 = p.join(dir2.path, '$command.exe');
167+
String expectedPath = fs.path.join(dir1.path, '$command.exe');
168+
String wrongPath1 = fs.path.join(dir1.path, '$command.bat');
169+
String wrongPath2 = fs.path.join(dir2.path, '$command.exe');
167170
fs.file(expectedPath).createSync();
168171
fs.file(wrongPath1).createSync();
169172
fs.file(wrongPath2).createSync();
@@ -188,21 +191,23 @@ void main() {
188191
);
189192
expect(executablePath, isNull);
190193
});
191-
}, skip: 'https://github.com/google/file.dart/issues/68');
194+
});
192195

193196
group('on Linux', () {
194197
Platform platform;
195198

199+
initialize(FileSystemStyle.posix);
200+
196201
setUp(() {
197202
platform = new FakePlatform(
198203
operatingSystem: 'linux',
199204
environment: <String, String>{'PATH': '${dir1.path}:${dir2.path}'});
200205
});
201206

202207
test('absolute', () {
203-
String command = p.join(dir3.path, 'bla');
208+
String command = fs.path.join(dir3.path, 'bla');
204209
String expectedPath = command;
205-
String wrongPath = p.join(dir3.path, 'bla.bat');
210+
String wrongPath = fs.path.join(dir3.path, 'bla.bat');
206211
fs.file(command).createSync();
207212
fs.file(wrongPath).createSync();
208213

@@ -217,8 +222,8 @@ void main() {
217222

218223
test('in path multiple times', () {
219224
String command = 'xxx';
220-
String expectedPath = p.join(dir1.path, command);
221-
String wrongPath = p.join(dir2.path, command);
225+
String expectedPath = fs.path.join(dir1.path, command);
226+
String wrongPath = fs.path.join(dir2.path, command);
222227
fs.file(expectedPath).createSync();
223228
fs.file(wrongPath).createSync();
224229

test/utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'dart:convert';
88
/// Decodes a UTF8-encoded byte array into a list of Strings, where each list
99
/// entry represents a line of text.
1010
List<String> decode(List<int> data) =>
11-
const LineSplitter().convert(UTF8.decode(data));
11+
const LineSplitter().convert(utf8.decode(data));
1212

1313
/// Consumes and returns an entire stream of bytes.
1414
Future<List<int>> consume(Stream<List<int>> stream) =>

0 commit comments

Comments
 (0)