Skip to content

Commit

Permalink
feat: update-goldens flag and exec
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy committed Dec 1, 2023
1 parent 3c313be commit babc9bd
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
"safe_ident": "unit",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
},
{
"comments": [],
Expand Down Expand Up @@ -160,7 +161,8 @@
"safe_ident": "unit",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
},
{
"comments": [],
Expand Down Expand Up @@ -198,7 +200,8 @@
"safe_ident": "unit",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
},
{
"comments": [],
Expand Down Expand Up @@ -236,7 +239,8 @@
"safe_ident": "unit",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
},
{
"comments": [],
Expand Down Expand Up @@ -274,7 +278,8 @@
"safe_ident": "unit",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
}
],
"has_executor": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
"enum_or_struct_name": "crate::api/MyEnum",
"mode": "Instance"
}
}
},
"rust_async": false
},
{
"comments": [],
Expand All @@ -81,7 +82,8 @@
"enum_or_struct_name": "crate::api/MyEnum",
"mode": "Static"
}
}
},
"rust_async": false
},
{
"comments": [],
Expand Down Expand Up @@ -125,7 +127,8 @@
"enum_or_struct_name": "crate::api/MyStruct",
"mode": "Instance"
}
}
},
"rust_async": false
}
],
"has_executor": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"safe_ident": "unit",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
},
{
"comments": [],
Expand All @@ -25,7 +26,8 @@
"safe_ident": "unit",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
}
],
"has_executor": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"safe_ident": "unit",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
},
{
"comments": [],
Expand All @@ -60,7 +61,8 @@
"safe_ident": "i_32",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
}
],
"has_executor": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"safe_ident": "unit",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
},
{
"comments": [],
Expand All @@ -60,7 +61,8 @@
"safe_ident": "i_32",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
},
{
"comments": [],
Expand All @@ -77,7 +79,8 @@
"safe_ident": "i_32",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
},
{
"comments": [],
Expand All @@ -94,7 +97,8 @@
"safe_ident": "i_32",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
}
],
"has_executor": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"safe_ident": "unit",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
}
],
"has_executor": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@
"safe_ident": "unit",
"type": "Primitive"
},
"owner": "Function"
"owner": "Function",
"rust_async": false
}
],
"has_executor": false,
Expand Down
3 changes: 3 additions & 0 deletions tools/frb_internal/lib/src/makefile_dart/misc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:build_cli_annotations/build_cli_annotations.dart';
import 'package:flutter_rust_bridge_internal/src/makefile_dart/consts.dart';
import 'package:flutter_rust_bridge_internal/src/makefile_dart/generate.dart';
import 'package:flutter_rust_bridge_internal/src/makefile_dart/lint.dart';
import 'package:flutter_rust_bridge_internal/src/makefile_dart/test.dart';
import 'package:flutter_rust_bridge_internal/src/utils/makefile_dart_infra.dart';

part 'misc.g.dart';
Expand Down Expand Up @@ -61,6 +62,8 @@ Future<void> precommit(PrecommitConfig config) async {
await generateRunFrbCodegenCommandGenerate(
GeneratePackageConfig(setExitIfChanged: false, package: package));
}

await testRust(const TestRustConfig(updateGoldens: true));
}
}

Expand Down
18 changes: 13 additions & 5 deletions tools/frb_internal/lib/src/makefile_dart/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ part 'test.g.dart';

List<Command<void>> createCommands() {
return [
SimpleConfigCommand('test-rust', testRust, _$populateTestConfigParser,
_$parseTestConfigResult),
SimpleConfigCommand('test-rust', testRust, _$populateTestRustConfigParser,
_$parseTestRustConfigResult),
SimpleConfigCommand('test-dart-native', testDartNative,
_$populateTestDartConfigParser, _$parseTestDartConfigResult),
SimpleConfigCommand('test-dart-web', testDartWeb,
Expand All @@ -29,6 +29,13 @@ class TestConfig {
const TestConfig();
}

@CliOptions()
class TestRustConfig {
final bool updateGoldens;

const TestRustConfig({required this.updateGoldens});
}

@CliOptions()
class TestDartConfig {
final String package;
Expand All @@ -44,17 +51,18 @@ class TestFlutterConfig {
const TestFlutterConfig({this.flutterTestArgs, required this.package});
}

Future<void> testRust(TestConfig config) async {
Future<void> testRust(TestRustConfig config) async {
for (final package in kRustPackages) {
await testRustPackage(package);
await testRustPackage(config, package);
}
}

Future<void> testRustPackage(String package) async {
Future<void> testRustPackage(TestRustConfig config, String package) async {
await exec('cargo build', relativePwd: package);
await exec('cargo test', relativePwd: package, extraEnv: {
// Because we have another CI to run the codegen and check outputs
'FRB_SKIP_GENERATE_FRB_EXAMPLE_TEST': '1',
if (config.updateGoldens) 'UPDATE_GOLDENS': '1',
});
}

Expand Down
16 changes: 16 additions & 0 deletions tools/frb_internal/lib/src/makefile_dart/test.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit babc9bd

Please sign in to comment.