testCodeBuildHook function

  1. @isTest
Future<void> testCodeBuildHook({
  1. required String description,
  2. required dynamic mainMethod(
    1. List<String> arguments
    ),
  3. required FutureOr<void> check(
    1. BuildConfig,
    2. BuildOutput
    ),
  4. BuildMode? buildMode,
  5. Architecture? targetArchitecture,
  6. OS? targetOS,
  7. IOSSdk? targetIOSSdk,
  8. int? targetIOSVersion,
  9. int? targetMacOSVersion,
  10. int? targetAndroidNdkApi,
  11. CCompilerConfig? cCompiler,
  12. LinkModePreference? linkModePreference,
  13. required List<String> supportedAssetTypes,
  14. bool? linkingEnabled,
})

Implementation

@isTest
Future<void> testCodeBuildHook({
  required String description,
  // ignore: inference_failure_on_function_return_type
  required Function(List<String> arguments) mainMethod,
  required FutureOr<void> Function(BuildConfig, BuildOutput) check,
  BuildMode? buildMode,
  Architecture? targetArchitecture,
  OS? targetOS,
  IOSSdk? targetIOSSdk,
  int? targetIOSVersion,
  int? targetMacOSVersion,
  int? targetAndroidNdkApi,
  CCompilerConfig? cCompiler,
  LinkModePreference? linkModePreference,
  required List<String> supportedAssetTypes,
  bool? linkingEnabled,
}) async {
  await testBuildHook(
    description: description,
    mainMethod: mainMethod,
    extraConfigSetup: (config) {
      config.setupCodeConfig(
        linkModePreference: linkModePreference ?? LinkModePreference.dynamic,
        cCompilerConfig: cCompiler,
        targetArchitecture: targetArchitecture ?? Architecture.current,
        targetIOSSdk: targetIOSSdk,
        targetIOSVersion: targetIOSVersion,
        targetMacOSVersion: targetMacOSVersion,
        targetAndroidNdkApi: targetAndroidNdkApi,
      );
    },
    check: (config, output) async {
      expect(await validateCodeAssetBuildOutput(config, output), isEmpty);
      await check(config, output);
    },
    buildMode: buildMode,
    targetOS: targetOS,
    supportedAssetTypes: supportedAssetTypes,
    linkingEnabled: linkingEnabled,
  );
}