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
cd57af14
Unverified
Commit
cd57af14
authored
Jan 19, 2021
by
Michael Goderbauer
Committed by
GitHub
Jan 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests that module/plugin/package templates can be migrated to null-safety (#74090)
parent
a0be9802
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
31 deletions
+82
-31
projectName_test.dart.tmpl
...r_tools/templates/package/test/projectName_test.dart.tmpl
+0
-1
migrate_test.dart
...es/flutter_tools/test/integration.shard/migrate_test.dart
+82
-30
No files found.
packages/flutter_tools/templates/package/test/projectName_test.dart.tmpl
View file @
cd57af14
...
@@ -8,6 +8,5 @@ void main() {
...
@@ -8,6 +8,5 @@ void main() {
expect(calculator.addOne(2), 3);
expect(calculator.addOne(2), 3);
expect(calculator.addOne(-7), -6);
expect(calculator.addOne(-7), -6);
expect(calculator.addOne(0), 1);
expect(calculator.addOne(0), 1);
expect(() => calculator.addOne(null), throwsNoSuchMethodError);
});
});
}
}
packages/flutter_tools/test/integration.shard/migrate_test.dart
View file @
cd57af14
...
@@ -8,43 +8,95 @@ import 'package:flutter_tools/src/base/io.dart';
...
@@ -8,43 +8,95 @@ import 'package:flutter_tools/src/base/io.dart';
import
'../src/common.dart'
;
import
'../src/common.dart'
;
import
'test_utils.dart'
;
import
'test_utils.dart'
;
/// Verifies that `dart migrate` will run successfully on the default `flutter create`
/// template.
void
main
(
)
{
void
main
(
)
{
/// Verifies that `dart migrate` will run successfully on the default `flutter create`
/// template.
testWithoutContext
(
'dart migrate succeeds on flutter create template'
,
()
async
{
testWithoutContext
(
'dart migrate succeeds on flutter create template'
,
()
async
{
final
String
flutterBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
platform
.
isWindows
?
'flutter.bat'
:
'flutter'
);
Directory
tempDir
;
final
String
dartBin
=
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
platform
.
isWindows
?
'dart.bat'
:
'dart'
);
try
{
tempDir
=
await
_createProject
(
tempDir
);
await
_migrate
(
tempDir
);
await
_analyze
(
tempDir
);
}
finally
{
tempDir
?.
deleteSync
(
recursive:
true
);
}
});
/// Verifies that `dart migrate` will run successfully on the module template
/// used by `flutter create --template=module`.
testWithoutContext
(
'dart migrate succeeds on module template'
,
()
async
{
Directory
tempDir
;
try
{
tempDir
=
await
_createProject
(
tempDir
,
<
String
>[
'--template=module'
]);
await
_migrate
(
tempDir
);
await
_analyze
(
tempDir
);
}
finally
{
tempDir
?.
deleteSync
(
recursive:
true
);
}
},
timeout:
const
Timeout
(
Duration
(
minutes:
1
)));
/// Verifies that `dart migrate` will run successfully on the module template
/// used by `flutter create --template=plugin`.
testWithoutContext
(
'dart migrate succeeds on plugin template'
,
()
async
{
Directory
tempDir
;
try
{
tempDir
=
await
_createProject
(
tempDir
,
<
String
>[
'--template=plugin'
]);
await
_migrate
(
tempDir
);
await
_analyze
(
tempDir
);
}
finally
{
tempDir
?.
deleteSync
(
recursive:
true
);
}
});
/// Verifies that `dart migrate` will run successfully on the module template
/// used by `flutter create --template=package`.
testWithoutContext
(
'dart migrate succeeds on package template'
,
()
async
{
Directory
tempDir
;
Directory
tempDir
;
try
{
try
{
tempDir
=
createResolvedTempDirectorySync
(
'dart_migrate_test.'
);
tempDir
=
await
_createProject
(
tempDir
,
<
String
>[
'--template=package'
]);
final
ProcessResult
createResult
=
await
processManager
.
run
(<
String
>[
await
_migrate
(
tempDir
);
flutterBin
,
await
_analyze
(
tempDir
);
'create'
,
'foo'
,
],
workingDirectory:
tempDir
.
path
);
if
(
createResult
.
exitCode
!=
0
)
{
fail
(
'flutter create did not work:
${createResult.stdout}${createResult.stderr}
'
);
}
final
ProcessResult
migrateResult
=
await
processManager
.
run
(<
String
>[
dartBin
,
'migrate'
,
'--apply-changes'
,
],
workingDirectory:
fileSystem
.
path
.
join
(
tempDir
.
path
,
'foo'
));
if
(
migrateResult
.
exitCode
!=
0
)
{
fail
(
'dart migrate did not work:
${migrateResult.stdout}${migrateResult.stderr}
'
);
}
final
ProcessResult
analyzeResult
=
await
processManager
.
run
(<
String
>[
flutterBin
,
'analyze'
,
],
workingDirectory:
fileSystem
.
path
.
join
(
tempDir
.
path
,
'foo'
));
if
(
analyzeResult
.
exitCode
!=
0
)
{
fail
(
'flutter analyze had errors:
${analyzeResult.stdout}${analyzeResult.stderr}
'
);
}
}
finally
{
}
finally
{
tempDir
?.
deleteSync
(
recursive:
true
);
tempDir
?.
deleteSync
(
recursive:
true
);
}
}
});
});
}
}
Future
<
Directory
>
_createProject
(
Directory
tempDir
,
[
List
<
String
>
extraAgs
])
async
{
tempDir
=
createResolvedTempDirectorySync
(
'dart_migrate_test.'
);
final
ProcessResult
createResult
=
await
processManager
.
run
(<
String
>[
_flutterBin
,
'create'
,
if
(
extraAgs
!=
null
)
...
extraAgs
,
'foo'
,
],
workingDirectory:
tempDir
.
path
);
if
(
createResult
.
exitCode
!=
0
)
{
fail
(
'flutter create did not work:
${createResult.stdout}${createResult.stderr}
'
);
}
return
tempDir
;
}
Future
<
void
>
_migrate
(
Directory
tempDir
)
async
{
final
ProcessResult
migrateResult
=
await
processManager
.
run
(<
String
>[
_dartBin
,
'migrate'
,
'--apply-changes'
,
],
workingDirectory:
fileSystem
.
path
.
join
(
tempDir
.
path
,
'foo'
));
if
(
migrateResult
.
exitCode
!=
0
)
{
fail
(
'dart migrate did not work:
${migrateResult.stdout}${migrateResult.stderr}
'
);
}
}
Future
<
void
>
_analyze
(
Directory
tempDir
)
async
{
final
ProcessResult
analyzeResult
=
await
processManager
.
run
(<
String
>[
_flutterBin
,
'analyze'
,
],
workingDirectory:
fileSystem
.
path
.
join
(
tempDir
.
path
,
'foo'
));
if
(
analyzeResult
.
exitCode
!=
0
)
{
fail
(
'flutter analyze had errors:
${analyzeResult.stdout}${analyzeResult.stderr}
'
);
}
}
String
get
_flutterBin
=>
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
platform
.
isWindows
?
'flutter.bat'
:
'flutter'
);
String
get
_dartBin
=>
fileSystem
.
path
.
join
(
getFlutterRoot
(),
'bin'
,
platform
.
isWindows
?
'dart.bat'
:
'dart'
);
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