[flutter_tools] Introducing arg option for specifying the output directory for web (#113076)

This commit is contained in:
Elias Yishak
2022-11-01 18:50:02 -04:00
committed by GitHub
parent 61deaef5df
commit 17ec3b1d15
5 changed files with 70 additions and 9 deletions

View File

@@ -84,7 +84,7 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
});
testUsingContext('Builds a web bundle - end to end', () async {
testUsingContext('Setup for a web build with default output directory', () async {
final BuildCommand buildCommand = BuildCommand();
final CommandRunner<void> runner = createTestCommandRunner(buildCommand);
setupFileSystemForEndToEndTest(fileSystem);
@@ -116,6 +116,48 @@ void main() {
}),
});
testUsingContext('Setup for a web build with a user specified output directory',
() async {
final BuildCommand buildCommand = BuildCommand();
final CommandRunner<void> runner = createTestCommandRunner(buildCommand);
setupFileSystemForEndToEndTest(fileSystem);
const String newBuildDir = 'new_dir';
final Directory buildDir = fileSystem.directory(fileSystem.path.join(newBuildDir));
expect(buildDir.existsSync(), false);
await runner.run(<String>[
'build',
'web',
'--no-pub',
'--output=$newBuildDir'
]);
expect(buildDir.existsSync(), true);
}, overrides: <Type, Generator>{
Platform: () => fakePlatform,
FileSystem: () => fileSystem,
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
ProcessManager: () => FakeProcessManager.any(),
BuildSystem: () => TestBuildSystem.all(BuildResult(success: true), (Target target, Environment environment) {
expect(environment.defines, <String, String>{
'TargetFile': 'lib/main.dart',
'HasWebPlugins': 'true',
'cspMode': 'false',
'SourceMaps': 'false',
'NativeNullAssertions': 'true',
'ServiceWorkerStrategy': 'offline-first',
'BuildMode': 'release',
'DartDefines': 'RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==',
'DartObfuscation': 'false',
'TrackWidgetCreation': 'false',
'TreeShakeIcons': 'false',
});
}),
});
testUsingContext('hidden if feature flag is not enabled', () async {
expect(BuildWebCommand(verboseHelp: false).hidden, true);
}, overrides: <Type, Generator>{