Skip to content

Commit 0b14abc

Browse files
pqcommit-bot@chromium.org
authored andcommitted
basic fix tests
Change-Id: I11e35c2585745ea60f19c27a9e9fa3ae757e99dc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168660 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Phil Quitslund <pquitslund@google.com>
1 parent 2ad8fde commit 0b14abc

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

pkg/dartdev/test/commands/fix_test.dart

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,53 @@ void main() {
1111
}
1212

1313
void defineFix() {
14-
// todo (pq): add tests when the `fix` command is enabled.
14+
TestProject p;
15+
16+
setUp(() => p = null);
17+
18+
tearDown(() => p?.dispose());
19+
20+
test('none', () {
21+
p = project(mainSrc: 'int get foo => 1;\n');
22+
var result = p.runSync('fix', [p.dirPath]);
23+
expect(result.exitCode, 0);
24+
expect(result.stderr, isEmpty);
25+
expect(result.stdout, contains('Nothing to fix!'));
26+
});
27+
28+
test('no args', () {
29+
p = project(
30+
mainSrc: '''
31+
var x = "";
32+
''',
33+
analysisOptions: '''
34+
linter:
35+
rules:
36+
- prefer_single_quotes
37+
''',
38+
);
39+
var result = p.runSync('fix', [], workingDir: p.dirPath);
40+
expect(result.exitCode, 0);
41+
expect(result.stderr, isEmpty);
42+
expect(result.stdout, contains('Fixed 1 files.'));
43+
});
44+
45+
test('.', () {
46+
p = project(
47+
mainSrc: '''
48+
var x = "";
49+
''',
50+
analysisOptions: '''
51+
linter:
52+
rules:
53+
- prefer_single_quotes
54+
''',
55+
);
56+
var result = p.runSync('fix', ['.'], workingDir: p.dirPath);
57+
expect(result.exitCode, 0);
58+
expect(result.stderr, isEmpty);
59+
expect(result.stdout, contains('Fixed 1 files.'));
60+
});
61+
62+
// todo (pq): add tests for analyzer excludes, ignores, etc.
1563
}

0 commit comments

Comments
 (0)