[flutter_tools] add support for dart defines to flutter test (#70791)

This commit is contained in:
Jonah Williams
2020-11-18 14:52:49 -08:00
committed by GitHub
parent e26c7f98ff
commit f4e79e6828
7 changed files with 31 additions and 49 deletions

View File

@@ -114,29 +114,6 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
Logger: () => BufferLogger.test(),
});
testUsingContext('TestCompiler reports an error when there is no dependency on flutter_test or test', () async {
final FakeTestCompiler testCompiler = FakeTestCompiler(
BuildInfo.debug,
FlutterProject.current(),
residentCompiler,
);
expect(await testCompiler.compile(Uri.parse('test/foo.dart')), null);
expect(testLogger.errorText, contains('Error: cannot run without a dependency on '
'either "package:flutter_test" or "package:test'));
verifyNever(residentCompiler.recompile(
any,
<Uri>[Uri.parse('test/foo.dart')],
outputPath: testCompiler.outputDill.path,
packageConfig: anyNamed('packageConfig'),
));
}, overrides: <Type, Generator>{
FileSystem: () => fileSystem,
Platform: () => linuxPlatform,
ProcessManager: () => FakeProcessManager.any(),
Logger: () => BufferLogger.test(),
});
}
/// Override the creation of the Resident Compiler to simplify testing.

View File

@@ -82,6 +82,11 @@ void main() {
return _testFile('package_assets', automatedTestsDirectory, flutterTestDirectory, exitCode: isZero);
});
testWithoutContext('flutter test should support dart defines', () async {
return _testFile('dart_defines', automatedTestsDirectory, flutterTestDirectory, exitCode: isZero,
extraArguments: <String>['--dart-define=flutter.test.foo=bar']);
});
testWithoutContext('flutter test should run a test when its name matches a regexp', () async {
final ProcessResult result = await _runFlutterTest('filtering', automatedTestsDirectory, flutterTestDirectory,
extraArguments: const <String>['--name', 'inc.*de']);