-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dont crash on test compilation error (#739)
* fix: dont crash on test compilation error * test everythin * it is justa an and
- Loading branch information
1 parent
6b61e9e
commit f19411c
Showing
10 changed files
with
197 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
e2e/test/commands/test/compilation_error/compilation_error_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'package:mason/mason.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
import 'package:test/test.dart'; | ||
import 'package:universal_io/io.dart'; | ||
|
||
import '../../../../helpers/helpers.dart'; | ||
|
||
void main() { | ||
test( | ||
'fails when there is a compilation error, but does not crash', | ||
timeout: const Timeout(Duration(minutes: 2)), | ||
withRunner((commandRunner, logger, updater, logs) async { | ||
final tempDirectory = | ||
Directory.systemTemp.createTempSync('compilation_error'); | ||
addTearDown(() => tempDirectory.deleteSync(recursive: true)); | ||
|
||
await copyDirectory( | ||
Directory('test/commands/test/compilation_error/fixture'), | ||
tempDirectory, | ||
); | ||
|
||
await expectSuccessfulProcessResult( | ||
'flutter', | ||
['pub', 'get'], | ||
workingDirectory: tempDirectory.path, | ||
); | ||
|
||
final cwd = Directory.current; | ||
Directory.current = tempDirectory; | ||
addTearDown(() { | ||
Directory.current = cwd; | ||
}); | ||
|
||
final result = await commandRunner.run(['test']); | ||
|
||
expect(result, equals(ExitCode.unavailable.code)); | ||
verify( | ||
() => logger.err(any(that: contains('- test/.test_optimizer.dart'))), | ||
).called(1); | ||
}), | ||
); | ||
} |
3 changes: 3 additions & 0 deletions
3
e2e/test/commands/test/compilation_error/fixture/analysis_options.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
analyzer: | ||
exclude: | ||
- test |
3 changes: 3 additions & 0 deletions
3
e2e/test/commands/test/compilation_error/fixture/lib/compilation_error.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Thing { | ||
const Thing(); | ||
} |
9 changes: 9 additions & 0 deletions
9
e2e/test/commands/test/compilation_error/fixture/pubspec.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: compilation_error | ||
version: 0.1.0+1 | ||
publish_to: none | ||
|
||
environment: | ||
sdk: ">=2.19.0 <3.0.0" | ||
|
||
dev_dependencies: | ||
test: ^1.19.2 |
10 changes: 10 additions & 0 deletions
10
e2e/test/commands/test/compilation_error/fixture/test/src/my_package_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// ignore_for_file: prefer_const_constructors | ||
|
||
import 'package:compilation_error/compilation_error.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('can be instantiated', () { | ||
expect(Thing(thing: true), isNull); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters