Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f4e79e68
Unverified
Commit
f4e79e68
authored
Nov 18, 2020
by
Jonah Williams
Committed by
GitHub
Nov 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] add support for dart defines to flutter test (#70791)
parent
e26c7f98
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
49 deletions
+31
-49
dart_defines_expectation.txt
...automated_tests/flutter_test/dart_defines_expectation.txt
+1
-0
dart_defines_test.dart
dev/automated_tests/flutter_test/dart_defines_test.dart
+11
-0
test.dart
packages/flutter_tools/lib/src/commands/test.dart
+13
-0
runner.dart
packages/flutter_tools/lib/src/test/runner.dart
+0
-3
test_compiler.dart
packages/flutter_tools/lib/src/test/test_compiler.dart
+1
-23
test_compiler_test.dart
.../flutter_tools/test/general.shard/test_compiler_test.dart
+0
-23
test_test.dart
packages/flutter_tools/test/integration.shard/test_test.dart
+5
-0
No files found.
dev/automated_tests/flutter_test/dart_defines_expectation.txt
0 → 100644
View file @
f4e79e68
[0-9]+:[0-9]+ [+]1: All tests passed!
dev/automated_tests/flutter_test/dart_defines_test.dart
0 → 100644
View file @
f4e79e68
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter_test/flutter_test.dart'
;
void
main
(
)
{
test
(
'Dart defines can be provided'
,
()
{
expect
(
const
String
.
fromEnvironment
(
'flutter.test.foo'
),
'bar'
);
});
}
packages/flutter_tools/lib/src/commands/test.dart
View file @
f4e79e68
...
...
@@ -31,6 +31,7 @@ class TestCommand extends FlutterCommand {
addNullSafetyModeOptions
(
hide:
!
verboseHelp
);
usesTrackWidgetCreation
(
verboseHelp:
verboseHelp
);
addEnableExperimentation
(
hide:
!
verboseHelp
);
usesDartDefineOption
();
argParser
..
addMultiOption
(
'name'
,
help:
'A regular expression matching substrings of the names of tests to run.'
,
...
...
@@ -184,6 +185,18 @@ class TestCommand extends FlutterCommand {
final
String
excludeTags
=
stringArg
(
'exclude-tags'
);
final
BuildInfo
buildInfo
=
await
getBuildInfo
(
forcedBuildMode:
BuildMode
.
debug
);
if
(
buildInfo
.
packageConfig
[
'test_api'
]
==
null
)
{
globals
.
printError
(
'
\n
'
'Error: cannot run without a dependency on either "package:flutter_test" or "package:test". '
'Ensure the following lines are present in your pubspec.yaml:'
'
\n\n
'
'dev_dependencies:
\n
'
' flutter_test:
\n
'
' sdk: flutter
\n
'
,
);
}
if
(
buildTestAssets
&&
flutterProject
.
manifest
.
assets
.
isNotEmpty
)
{
await
_buildTestAsset
();
}
...
...
packages/flutter_tools/lib/src/test/runner.dart
View file @
f4e79e68
...
...
@@ -90,9 +90,6 @@ class _FlutterTestRunnerImpl implements FlutterTestRunner {
})
async
{
// Configure package:test to use the Flutter engine for child processes.
final
String
shellPath
=
globals
.
artifacts
.
getArtifactPath
(
Artifact
.
flutterTester
);
if
(!
globals
.
processManager
.
canRun
(
shellPath
))
{
throwToolExit
(
'Cannot execute Flutter tester at
$shellPath
'
);
}
// Compute the command-line arguments for package:test.
final
List
<
String
>
testArgs
=
<
String
>[
...
...
packages/flutter_tools/lib/src/test/test_compiler.dart
View file @
f4e79e68
...
...
@@ -5,7 +5,6 @@
import
'dart:async'
;
import
'package:meta/meta.dart'
;
import
'package:package_config/package_config.dart'
;
import
'../artifacts.dart'
;
import
'../base/file_system.dart'
;
...
...
@@ -114,8 +113,6 @@ class TestCompiler {
return
residentCompiler
;
}
PackageConfig
_packageConfig
;
// Handle a compilation request.
Future
<
void
>
_onCompilationRequest
(
_CompilationRequest
request
)
async
{
final
bool
isEmpty
=
compilationQueue
.
isEmpty
;
...
...
@@ -126,25 +123,6 @@ class TestCompiler {
if
(!
isEmpty
)
{
return
;
}
if
(
_packageConfig
==
null
)
{
_packageConfig
??=
buildInfo
.
packageConfig
;
// Compilation will fail if there is no flutter_test dependency, since
// this library is imported by the generated entrypoint script.
if
(
_packageConfig
[
'test_api'
]
==
null
)
{
globals
.
printError
(
'
\n
'
'Error: cannot run without a dependency on either "package:flutter_test" or "package:test". '
'Ensure the following lines are present in your pubspec.yaml:'
'
\n\n
'
'dev_dependencies:
\n
'
' flutter_test:
\n
'
' sdk: flutter
\n
'
,
);
request
.
result
.
complete
(
null
);
await
compilerController
.
close
();
return
;
}
}
while
(
compilationQueue
.
isNotEmpty
)
{
final
_CompilationRequest
request
=
compilationQueue
.
first
;
globals
.
printTrace
(
'Compiling
${request.mainUri}
'
);
...
...
@@ -158,7 +136,7 @@ class TestCompiler {
request
.
mainUri
,
<
Uri
>[
request
.
mainUri
],
outputPath:
outputDill
.
path
,
packageConfig:
_
packageConfig
,
packageConfig:
buildInfo
.
packageConfig
,
);
final
String
outputPath
=
compilerOutput
?.
outputFilename
;
...
...
packages/flutter_tools/test/general.shard/test_compiler_test.dart
View file @
f4e79e68
...
...
@@ -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.
...
...
packages/flutter_tools/test/integration.shard/test_test.dart
View file @
f4e79e68
...
...
@@ -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'
]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment