[flutter_tools] Add --build-number and --build-name support to web and linux (#100377)
This commit is contained in:
@@ -148,6 +148,31 @@ void main() {
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
BuildSystem: () => TestBuildSystem.all(BuildResult(success: true)),
|
||||
});
|
||||
|
||||
testUsingContext('Web build supports build-name and build-number', () async {
|
||||
final TestWebBuildCommand buildCommand = TestWebBuildCommand();
|
||||
final CommandRunner<void> runner = createTestCommandRunner(buildCommand);
|
||||
setupFileSystemForEndToEndTest(fileSystem);
|
||||
|
||||
await runner.run(<String>[
|
||||
'build',
|
||||
'web',
|
||||
'--no-pub',
|
||||
'--build-name=1.2.3',
|
||||
'--build-number=42',
|
||||
]);
|
||||
|
||||
final BuildInfo buildInfo = await buildCommand.webCommand
|
||||
.getBuildInfo(forcedBuildMode: BuildMode.debug);
|
||||
expect(buildInfo.buildNumber, '42');
|
||||
expect(buildInfo.buildName, '1.2.3');
|
||||
}, overrides: <Type, Generator>{
|
||||
Platform: () => fakePlatform,
|
||||
FileSystem: () => fileSystem,
|
||||
FeatureFlags: () => TestFeatureFlags(isWebEnabled: true),
|
||||
ProcessManager: () => FakeProcessManager.any(),
|
||||
BuildSystem: () => TestBuildSystem.all(BuildResult(success: true)),
|
||||
});
|
||||
}
|
||||
|
||||
void setupFileSystemForEndToEndTest(FileSystem fileSystem) {
|
||||
|
||||
@@ -121,6 +121,8 @@ void main() {
|
||||
codeSizeDirectory: 'foo/code-size',
|
||||
fileSystemRoots: <String>['test5', 'test6'],
|
||||
fileSystemScheme: 'scheme',
|
||||
buildName: '122',
|
||||
buildNumber: '22'
|
||||
);
|
||||
|
||||
expect(buildInfo.toBuildSystemEnvironment(), <String, String>{
|
||||
@@ -136,6 +138,8 @@ void main() {
|
||||
'CodeSizeDirectory': 'foo/code-size',
|
||||
'FileSystemRoots': 'test5,test6',
|
||||
'FileSystemScheme': 'scheme',
|
||||
'BuildName': '122',
|
||||
'BuildNumber': '22',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -100,6 +100,8 @@ void main() {
|
||||
fileSystem.currentDirectory,
|
||||
defines: <String, String>{
|
||||
kBuildMode: 'debug',
|
||||
kBuildName: '2.0.0',
|
||||
kBuildNumber: '22',
|
||||
},
|
||||
inputs: <String, String>{
|
||||
kBundleSkSLPath: 'bundle.sksl',
|
||||
@@ -133,6 +135,9 @@ void main() {
|
||||
expect(output.childFile('kernel_blob.bin'), exists);
|
||||
expect(output.childFile('AssetManifest.json'), exists);
|
||||
expect(output.childFile('version.json'), exists);
|
||||
final String versionFile = output.childFile('version.json').readAsStringSync();
|
||||
expect(versionFile, contains('"version":"2.0.0"'));
|
||||
expect(versionFile, contains('"build_number":"22"'));
|
||||
// SkSL
|
||||
expect(output.childFile('io.flutter.shaders.json'), exists);
|
||||
expect(output.childFile('io.flutter.shaders.json').readAsStringSync(), '{"data":{"A":"B"}}');
|
||||
|
||||
@@ -102,6 +102,22 @@ void main() {
|
||||
expect(environment.outputDir.childFile('version.json'), exists);
|
||||
}));
|
||||
|
||||
test('override version values', () => testbed.run(() async {
|
||||
environment.defines[kBuildMode] = 'release';
|
||||
environment.defines[kBuildName] = '2.0.0';
|
||||
environment.defines[kBuildNumber] = '22';
|
||||
final Directory webResources = environment.projectDir.childDirectory('web');
|
||||
webResources.childFile('index.html').createSync(recursive: true);
|
||||
environment.buildDir.childFile('main.dart.js').createSync();
|
||||
await const WebReleaseBundle().build(environment);
|
||||
|
||||
final String versionFile = environment.outputDir
|
||||
.childFile('version.json')
|
||||
.readAsStringSync();
|
||||
expect(versionFile, contains('"version":"2.0.0"'));
|
||||
expect(versionFile, contains('"build_number":"22"'));
|
||||
}));
|
||||
|
||||
test('Base href is created in index.html with given base-href after release build', () => testbed.run(() async {
|
||||
environment.defines[kBuildMode] = 'release';
|
||||
environment.defines[kBaseHref] = '/basehreftest/';
|
||||
|
||||
Reference in New Issue
Block a user