Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[native_assets_cli] Make CCompilerConfig fields less nullable #1809

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

dcharkes
Copy link
Collaborator

Addressing:

Currently on Flutter and the Dart CI provide this information, and they always provide all 3. So this should not be a breaking change on the protocol level.

It is a breaking change on the API level.

@coveralls
Copy link

coveralls commented Dec 12, 2024

Coverage Status

coverage: 88.031% (-0.001%) from 88.032%
when pulling 0a7c91e on ccompiler-nullability
into 4d81ce6 on main.

@dcharkes dcharkes requested a review from mkustermann December 12, 2024 13:48
pkgs/native_assets_cli/lib/src/code_assets/validation.dart Outdated Show resolved Hide resolved
expect(codeConfig.cCompiler.compiler, fakeClang);
expect(codeConfig.cCompiler.linker, fakeLd);
expect(codeConfig.cCompiler.archiver, fakeAr);
expect(codeConfig.cCompiler?.compiler, fakeClang);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should this use ! - as we expect it to be non-nullable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the guidance is to prefer writing your tests in a way so that the error message is the most useful on failure:

https://pub.dev/packages/matcher

Prefer semantically meaningful matchers to comparing derived values.
Matchers which have knowledge of the semantics that are tested are able to emit more meaningful messages which don't require reading test source to understand why the test failed.

A stack trace showing that ! failed will give no error message about the fakeClang path that was expected.

@@ -10,13 +10,13 @@ import '../utils/map.dart';
/// The configuration for a C toolchain.
final class CCompilerConfig {
/// Path to a C compiler.
late final Uri? compiler;
late final Uri compiler;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dcharkes you recently brought up the question why I named it config.codeConfig and the class CodeConfig and we said we could drop "config" iff we structured the LinkConfig differently.

=> The same applies here, would we want to rename CCompilerConfig -> CCompiler?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the class name should still include config. But the fields not. I have a CL that does that, but I'm not fully happy with how it looks, maybe it feels more natural to do config.codeConfig.androidConfig.ndkVersion rather than config.code.android.ndkVersion, I'll play around with it and send it out as draft PR for us to decide what we want.

@auto-submit auto-submit bot merged commit b86e34d into main Dec 12, 2024
24 checks passed
@auto-submit auto-submit bot deleted the ccompiler-nullability branch December 12, 2024 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants