build_ios_config_only_test.dart 2.41 KB
Newer Older
1 2 3 4 5 6 7 8 9
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:file_testing/file_testing.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/io.dart';

import '../src/common.dart';
10
import 'test_utils.dart';
11 12 13

void main() {
  test('flutter build ios --config only updates generated xcconfig file without performing build', () async {
14 15 16 17 18 19
    final String workingDirectory = fileSystem.path.join(
      getFlutterRoot(),
      'dev',
      'integration_tests',
      'flutter_gallery',
    );
20
    final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
21

22
    await processManager.run(<String>[
23
      flutterBin,
24
      ...getLocalEngineArguments(),
25
      'clean',
26
    ], workingDirectory: workingDirectory);
27
    final List<String> buildCommand = <String>[
28
      flutterBin,
29
      ...getLocalEngineArguments(),
30 31 32 33 34 35 36
      'build',
      'ios',
      '--config-only',
      '--release',
      '--obfuscate',
      '--split-debug-info=info',
      '--no-codesign',
37 38
    ];
    final ProcessResult firstRunResult = await processManager.run(buildCommand, workingDirectory: workingDirectory);
39

40
    expect(firstRunResult, const ProcessResultMatcher(stdoutPattern: 'Running pod install'));
41

42 43 44 45 46 47
    final File generatedConfig = fileSystem.file(fileSystem.path.join(
      workingDirectory,
      'ios',
      'Flutter',
      'Generated.xcconfig',
    ));
48 49 50

    // Config is updated if command succeeded.
    expect(generatedConfig, exists);
51
    expect(generatedConfig.readAsStringSync(), contains('DART_OBFUSCATION=true'));
52 53

    // file that only exists if app was fully built.
54 55 56 57 58 59 60 61
    final File frameworkPlist = fileSystem.file(fileSystem.path.join(
      workingDirectory,
      'build',
      'ios',
      'iphoneos',
      'Runner.app',
      'AppFrameworkInfo.plist',
    ));
62 63

    expect(frameworkPlist, isNot(exists));
64 65 66 67 68

    // Run again with no changes.
    final ProcessResult secondRunResult = await processManager.run(buildCommand, workingDirectory: workingDirectory);
    final String secondRunStdout = secondRunResult.stdout.toString();

69
    expect(secondRunResult, const ProcessResultMatcher());
70 71
    // Do not run "pod install" when nothing changes.
    expect(secondRunStdout, isNot(contains('pod install')));
72
  }, skip: !platform.isMacOS); // [intended] iOS builds only work on macos.
73
}