build_ios_config_only_test.dart 1.94 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
    final String woringDirectory = fileSystem.path.join(getFlutterRoot(), 'examples', 'hello_world');
    final String flutterBin = fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');
16

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

    print(result.stdout);
    print(result.stderr);

    expect(result.exitCode, 0);

39 40
    final File generatedConfig = fileSystem.file(
      fileSystem.path.join(woringDirectory, 'ios', 'Flutter', 'Generated.xcconfig'));
41 42 43 44 45

    // Config is updated if command succeeded.
    expect(generatedConfig, exists);
    expect(generatedConfig.readAsStringSync(), allOf(
      contains('DART_OBFUSCATION=true'),
46
      contains('FLUTTER_FRAMEWORK_DIR=${fileSystem.path.absolute(getFlutterRoot(), 'bin', 'cache', 'artifacts', 'engine')}'),
47 48 49
    ));

    // file that only exists if app was fully built.
50 51
    final File frameworkPlist = fileSystem.file(
      fileSystem.path.join(woringDirectory, 'build', 'ios', 'iphoneos', 'Runner.app', 'AppFrameworkInfo.plist'));
52 53

    expect(frameworkPlist, isNot(exists));
54
  }, skip: !platform.isMacOS);
55
}