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
0a1385d9
Commit
0a1385d9
authored
Nov 10, 2015
by
Ian Hickson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #66 from Hixie/better-tests
Run 'pub get' the first time the tests are run
parents
f0ebc2b0
bd69e2c4
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
14 deletions
+43
-14
init.dart
packages/flutter_tools/lib/src/commands/init.dart
+6
-6
test.dart
packages/flutter_tools/lib/src/commands/test.dart
+23
-3
process.dart
packages/flutter_tools/lib/src/process.dart
+11
-5
loader.dart
packages/flutter_tools/lib/src/test/loader.dart
+3
-0
No files found.
packages/flutter_tools/lib/src/commands/init.dart
View file @
0a1385d9
...
...
@@ -59,12 +59,12 @@ class InitCommand extends Command {
if
(
argResults
[
'pub'
])
{
print
(
"Running pub get..."
);
Process
process
=
await
Process
.
star
t
(
sdkBinaryName
(
'pub'
),
[
'get'
],
workingDirectory:
out
.
path
);
stdout
.
addStream
(
process
.
stdout
);
stderr
.
addStream
(
process
.
stderr
);
i
nt
code
=
await
process
.
exitCode
;
if
(
code
!=
0
)
return
code
;
int
code
=
await
runCommandAndStreamOutpu
t
(
[
sdkBinaryName
(
'pub'
),
'get'
],
workingDirectory:
out
.
path
);
i
f
(
code
!=
0
)
return
code
;
}
print
(
message
);
...
...
packages/flutter_tools/lib/src/commands/test.dart
View file @
0a1385d9
...
...
@@ -11,6 +11,7 @@ import 'package:test/src/executable.dart' as executable;
import
'../artifacts.dart'
;
import
'../build_configuration.dart'
;
import
'../process.dart'
;
import
'../test/loader.dart'
as
loader
;
import
'flutter_command.dart'
;
...
...
@@ -36,7 +37,8 @@ class TestCommand extends FlutterCommand {
@override
Future
<
int
>
runInProject
()
async
{
List
<
String
>
testArgs
=
argResults
.
rest
.
toList
();
Directory
testDir
=
new
Directory
(
path
.
join
(
ArtifactStore
.
flutterRoot
,
'packages/unit/test'
));
Directory
flutterDir
=
new
Directory
(
path
.
join
(
ArtifactStore
.
flutterRoot
,
'packages/unit'
));
// see https://github.com/flutter/flutter/issues/50
Directory
testDir
=
new
Directory
(
path
.
join
(
flutterDir
.
path
,
'test'
));
if
(
testArgs
.
isEmpty
)
{
testArgs
.
addAll
(
testDir
.
listSync
(
recursive:
true
,
followLinks:
false
)
.
where
((
FileSystemEntity
entity
)
=>
entity
.
path
.
endsWith
(
'_test.dart'
)
&&
FileSystemEntity
.
isFileSync
(
entity
.
path
))
...
...
@@ -47,9 +49,27 @@ class TestCommand extends FlutterCommand {
testArgs
.
insert
(
0
,
'--no-color'
);
List
<
BuildConfiguration
>
configs
=
buildConfigurations
;
bool
foundOne
=
false
;
File
pubSpecYaml
=
new
File
(
path
.
join
(
flutterDir
.
path
,
'pubspec.yaml'
));
File
pubSpecLock
=
new
File
(
path
.
join
(
flutterDir
.
path
,
'pubspec.lock'
));
if
(!
pubSpecYaml
.
existsSync
())
{
print
(
'
${flutterDir.path}
has no pubspec.yaml'
);
return
1
;
}
if
(!
pubSpecLock
.
existsSync
()
||
pubSpecYaml
.
lastModifiedSync
().
isAfter
(
pubSpecLock
.
lastModifiedSync
()))
{
print
(
"Running pub get..."
);
int
code
=
await
runCommandAndStreamOutput
(
[
sdkBinaryName
(
'pub'
),
'get'
],
workingDirectory:
flutterDir
.
path
);
if
(
code
!=
0
)
return
code
;
}
String
currentDirectory
=
Directory
.
current
.
path
;
Directory
.
current
=
testDir
.
path
;
// TODO(ianh): Verify that this directory has had 'pub get' run in it at least once.
Directory
.
current
=
flutterDir
.
path
;
loader
.
installHook
();
for
(
BuildConfiguration
config
in
configs
)
{
if
(!
config
.
testable
)
...
...
packages/flutter_tools/lib/src/process.dart
View file @
0a1385d9
...
...
@@ -12,11 +12,17 @@ final Logger _logging = new Logger('sky_tools.process');
/// This runs the command and streams stdout/stderr from the child process to
/// this process' stdout/stderr.
Future
<
int
>
runCommandAndStreamOutput
(
List
<
String
>
cmd
,
{
String
prefix:
''
,
RegExp
filter
})
async
{
Future
<
int
>
runCommandAndStreamOutput
(
List
<
String
>
cmd
,
{
String
prefix:
''
,
RegExp
filter
,
String
workingDirectory
})
async
{
_logging
.
info
(
cmd
.
join
(
' '
));
Process
proc
=
await
Process
.
start
(
cmd
[
0
],
cmd
.
getRange
(
1
,
cmd
.
length
).
toList
());
Process
proc
=
await
Process
.
start
(
cmd
[
0
],
cmd
.
getRange
(
1
,
cmd
.
length
).
toList
(),
workingDirectory:
workingDirectory
);
proc
.
stdout
.
transform
(
UTF8
.
decoder
).
listen
((
String
data
)
{
List
<
String
>
dataLines
=
data
.
trimRight
().
split
(
'
\n
'
);
if
(
filter
!=
null
)
{
...
...
@@ -65,7 +71,7 @@ String runSync(List<String> cmd) => _runWithLoggingSync(cmd);
/// Return the platform specific name for the given Dart SDK binary. So, `pub`
/// ==> `pub.bat`.
String
sdkBinaryName
(
String
name
)
{
return
Platform
.
isWindows
?
'
$
{name}
.bat'
:
name
;
return
Platform
.
isWindows
?
'
$
name
.bat'
:
name
;
}
String
_runWithLoggingSync
(
List
<
String
>
cmd
,
{
bool
checked:
false
})
{
...
...
packages/flutter_tools/lib/src/test/loader.dart
View file @
0a1385d9
...
...
@@ -120,6 +120,9 @@ void main() {
case
-
0x0b
:
// ProcessSignal.SIGSEGV
output
+=
'Segmentation fault in subprocess for:
$path
\n
'
;
break
;
case
-
0x06
:
// ProcessSignal.SIGABRT
output
+=
'Aborted while running:
$path
\n
'
;
break
;
default
:
output
+=
'Unexpected exit code
$exitCode
from subprocess for:
$path
\n
'
;
}
...
...
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