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
91ae1409
Unverified
Commit
91ae1409
authored
Aug 27, 2019
by
Zachary Anderson
Committed by
GitHub
Aug 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Create a temp snapshot to run create_test.dart tests (#39338)
parent
5667b782
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
18 deletions
+89
-18
create_test.dart
...lutter_tools/test/general.shard/commands/create_test.dart
+89
-18
No files found.
packages/flutter_tools/test/general.shard/commands/create_test.dart
View file @
91ae1409
...
@@ -43,8 +43,9 @@ void main() {
...
@@ -43,8 +43,9 @@ void main() {
FlutterVersion
mockFlutterVersion
;
FlutterVersion
mockFlutterVersion
;
LoggingProcessManager
loggingProcessManager
;
LoggingProcessManager
loggingProcessManager
;
setUpAll
(()
{
setUpAll
(()
async
{
Cache
.
disableLocking
();
Cache
.
disableLocking
();
await
_ensureFlutterToolsSnapshot
();
});
});
setUp
(()
{
setUp
(()
{
...
@@ -58,6 +59,10 @@ void main() {
...
@@ -58,6 +59,10 @@ void main() {
tryToDelete
(
tempDir
);
tryToDelete
(
tempDir
);
});
});
tearDownAll
(()
async
{
await
_restoreFlutterToolsSnapshot
();
});
// Verify that we create a default project ('app') that is
// Verify that we create a default project ('app') that is
// well-formed.
// well-formed.
testUsingContext
(
'can create a default project'
,
()
async
{
testUsingContext
(
'can create a default project'
,
()
async
{
...
@@ -116,20 +121,24 @@ void main() {
...
@@ -116,20 +121,24 @@ void main() {
testUsingContext
(
'cannot create a project if non-empty non-project directory exists with .metadata'
,
()
async
{
testUsingContext
(
'cannot create a project if non-empty non-project directory exists with .metadata'
,
()
async
{
await
projectDir
.
absolute
.
childDirectory
(
'blag'
).
create
(
recursive:
true
);
await
projectDir
.
absolute
.
childDirectory
(
'blag'
).
create
(
recursive:
true
);
await
projectDir
.
absolute
.
childFile
(
'.metadata'
).
writeAsString
(
'project_type: blag
\n
'
);
await
projectDir
.
absolute
.
childFile
(
'.metadata'
).
writeAsString
(
'project_type: blag
\n
'
);
expect
(
expect
(()
async
=>
await
_createAndAnalyzeProject
(
()
async
=>
await
_createAndAnalyzeProject
(
projectDir
,
<
String
>[],
<
String
>[],
unexpectedPaths:
<
String
>[
projectDir
,
'android/'
,
<
String
>[],
'ios/'
,
<
String
>[],
'.android/'
,
unexpectedPaths:
<
String
>[
'.ios/'
,
'android/'
,
]),
'ios/'
,
throwsToolExit
(
message:
'Sorry, unable to detect the type of project to recreate'
));
'.android/'
,
'.ios/'
,
]),
throwsToolExit
(
message:
'Sorry, unable to detect the type of project to recreate'
));
},
timeout:
allowForRemotePubInvocation
,
overrides:
noColorTerminalOverride
);
},
timeout:
allowForRemotePubInvocation
,
overrides:
noColorTerminalOverride
);
testUsingContext
(
'Will create an app project if non-empty non-project directory exists without .metadata'
,
()
async
{
testUsingContext
(
'Will create an app project if non-empty non-project directory exists without .metadata'
,
()
async
{
await
projectDir
.
absolute
.
childDirectory
(
'blag'
).
create
(
recursive:
true
);
await
projectDir
.
absolute
.
childDirectory
(
'blag'
).
create
(
recursive:
true
);
await
projectDir
.
absolute
.
childDirectory
(
'.idea'
).
create
(
recursive:
true
);
await
projectDir
.
absolute
.
childDirectory
(
'.idea'
).
create
(
recursive:
true
);
await
_createAndAnalyzeProject
(
projectDir
,
await
_createAndAnalyzeProject
(
projectDir
,
<
String
>[
<
String
>[
'-i'
,
'objc'
,
'-a'
,
'java'
'-i'
,
'objc'
,
'-a'
,
'java'
],
<
String
>[
],
<
String
>[
...
@@ -148,7 +157,8 @@ void main() {
...
@@ -148,7 +157,8 @@ void main() {
testUsingContext
(
'detects and recreates an app project correctly'
,
()
async
{
testUsingContext
(
'detects and recreates an app project correctly'
,
()
async
{
await
projectDir
.
absolute
.
childDirectory
(
'lib'
).
create
(
recursive:
true
);
await
projectDir
.
absolute
.
childDirectory
(
'lib'
).
create
(
recursive:
true
);
await
projectDir
.
absolute
.
childDirectory
(
'ios'
).
create
(
recursive:
true
);
await
projectDir
.
absolute
.
childDirectory
(
'ios'
).
create
(
recursive:
true
);
await
_createAndAnalyzeProject
(
projectDir
,
await
_createAndAnalyzeProject
(
projectDir
,
<
String
>[
<
String
>[
'-i'
,
'objc'
,
'-a'
,
'java'
'-i'
,
'objc'
,
'-a'
,
'java'
],
<
String
>[
],
<
String
>[
...
@@ -1104,7 +1114,6 @@ void main() {
...
@@ -1104,7 +1114,6 @@ void main() {
});
});
}
}
Future
<
void
>
_createProject
(
Future
<
void
>
_createProject
(
Directory
dir
,
Directory
dir
,
List
<
String
>
createArgs
,
List
<
String
>
createArgs
,
...
@@ -1149,15 +1158,74 @@ Future<void> _createAndAnalyzeProject(
...
@@ -1149,15 +1158,74 @@ Future<void> _createAndAnalyzeProject(
await
_analyzeProject
(
dir
.
path
);
await
_analyzeProject
(
dir
.
path
);
}
}
Future
<
void
>
_
analyzeProject
(
String
workingDir
)
async
{
Future
<
void
>
_
ensureFlutterToolsSnapshot
(
)
async
{
final
String
flutterToolsPath
=
fs
.
path
.
absolute
(
fs
.
path
.
join
(
final
String
flutterToolsPath
=
fs
.
path
.
absolute
(
fs
.
path
.
join
(
'bin'
,
'bin'
,
'flutter_tools.dart'
,
'flutter_tools.dart'
,
));
));
final
String
flutterToolsSnapshotPath
=
fs
.
path
.
absolute
(
fs
.
path
.
join
(
'..'
,
'..'
,
'bin'
,
'cache'
,
'flutter_tools.snapshot'
,
));
final
String
dotPackages
=
fs
.
path
.
absolute
(
fs
.
path
.
join
(
'.packages'
,
));
final
List
<
String
>
args
=
<
String
>[
final
File
snapshotFile
=
fs
.
file
(
flutterToolsSnapshotPath
);
if
(
snapshotFile
.
existsSync
())
{
snapshotFile
.
renameSync
(
flutterToolsSnapshotPath
+
'.bak'
);
}
final
List
<
String
>
snapshotArgs
=
<
String
>[
...
dartVmFlags
,
...
dartVmFlags
,
'--snapshot=
$flutterToolsSnapshotPath
'
,
'--packages=
$dotPackages
'
,
flutterToolsPath
,
flutterToolsPath
,
];
final
ProcessResult
snapshotResult
=
await
Process
.
run
(
'../../bin/cache/dart-sdk/bin/dart'
,
snapshotArgs
,
);
if
(
snapshotResult
.
exitCode
!=
0
)
{
print
(
snapshotResult
.
stdout
);
print
(
snapshotResult
.
stderr
);
}
expect
(
snapshotResult
.
exitCode
,
0
);
}
Future
<
void
>
_restoreFlutterToolsSnapshot
()
async
{
final
String
flutterToolsSnapshotPath
=
fs
.
path
.
absolute
(
fs
.
path
.
join
(
'..'
,
'..'
,
'bin'
,
'cache'
,
'flutter_tools.snapshot'
,
));
final
File
snapshotBackup
=
fs
.
file
(
flutterToolsSnapshotPath
+
'.bak'
);
if
(!
snapshotBackup
.
existsSync
())
{
// No backup to restore.
return
;
}
snapshotBackup
.
renameSync
(
flutterToolsSnapshotPath
);
}
Future
<
void
>
_analyzeProject
(
String
workingDir
)
async
{
final
String
flutterToolsSnapshotPath
=
fs
.
path
.
absolute
(
fs
.
path
.
join
(
'..'
,
'..'
,
'bin'
,
'cache'
,
'flutter_tools.snapshot'
,
));
final
List
<
String
>
args
=
<
String
>[
...
dartVmFlags
,
flutterToolsSnapshotPath
,
'analyze'
,
'analyze'
,
];
];
...
@@ -1174,9 +1242,12 @@ Future<void> _analyzeProject(String workingDir) async {
...
@@ -1174,9 +1242,12 @@ Future<void> _analyzeProject(String workingDir) async {
}
}
Future
<
void
>
_runFlutterTest
(
Directory
workingDir
,
{
String
target
})
async
{
Future
<
void
>
_runFlutterTest
(
Directory
workingDir
,
{
String
target
})
async
{
final
String
flutterToolsPath
=
fs
.
path
.
absolute
(
fs
.
path
.
join
(
final
String
flutterToolsSnapshotPath
=
fs
.
path
.
absolute
(
fs
.
path
.
join
(
'..'
,
'..'
,
'bin'
,
'bin'
,
'flutter_tools.dart'
,
'cache'
,
'flutter_tools.snapshot'
,
));
));
// While flutter test does get packages, it doesn't write version
// While flutter test does get packages, it doesn't write version
...
@@ -1185,7 +1256,7 @@ Future<void> _runFlutterTest(Directory workingDir, { String target }) async {
...
@@ -1185,7 +1256,7 @@ Future<void> _runFlutterTest(Directory workingDir, { String target }) async {
'
$dartSdkPath
/bin/dart'
,
'
$dartSdkPath
/bin/dart'
,
<
String
>[
<
String
>[
...
dartVmFlags
,
...
dartVmFlags
,
flutterToolsPath
,
flutterTools
Snapshot
Path
,
'packages'
,
'packages'
,
'get'
,
'get'
,
],
],
...
@@ -1194,7 +1265,7 @@ Future<void> _runFlutterTest(Directory workingDir, { String target }) async {
...
@@ -1194,7 +1265,7 @@ Future<void> _runFlutterTest(Directory workingDir, { String target }) async {
final
List
<
String
>
args
=
<
String
>[
final
List
<
String
>
args
=
<
String
>[
...
dartVmFlags
,
...
dartVmFlags
,
flutterToolsPath
,
flutterTools
Snapshot
Path
,
'test'
,
'test'
,
'--no-color'
,
'--no-color'
,
if
(
target
!=
null
)
target
,
if
(
target
!=
null
)
target
,
...
...
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