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

Add dart define from file #2232

Merged
merged 16 commits into from
Jun 24, 2024
Merged

Add dart define from file #2232

merged 16 commits into from
Jun 24, 2024

Conversation

pdenert
Copy link
Collaborator

@pdenert pdenert commented Jun 19, 2024

Close #1742

@pdenert pdenert self-assigned this Jun 19, 2024
@github-actions github-actions bot added the package: patrol_cli Related to the patrol_cli package label Jun 19, 2024
README.md Outdated Show resolved Hide resolved
packages/patrol_cli/lib/src/commands/build_android.dart Outdated Show resolved Hide resolved
packages/patrol_cli/lib/src/crossplatform/app_options.dart Outdated Show resolved Hide resolved
packages/patrol_cli/lib/src/dart_defines_reader.dart Outdated Show resolved Hide resolved
packages/patrol_cli/lib/src/dart_defines_reader.dart Outdated Show resolved Hide resolved
Comment on lines 30 to 42
Map<String, dynamic> fromConfigFile({required String path}) {
final filePath = _fs.path.join(_projectRoot.path, path);
final file = _fs.file(filePath);

if (!file.existsSync()) {
return {};
}

final jsonString = file.readAsStringSync();
final json = jsonDecode(jsonString) as Map<String, dynamic>;
return json;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

If the decision was made to completely parse the files into separate define's, then I would like it to work the same way as in flutter_tools:

  • fail if file is missing
  • do not add project Root.path at beginning of file path
  • support more than just JSON (maybe someone is using this)

How this is implemented in flutter_tools:
https://github.com/flutter/flutter/blob/64dd1ca9bc32fbc767a3f63e4c9c5ae2fc355380/packages/flutter_tools/lib/src/runner/flutter_command.dart#L1452-L1494

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks. Good notice! I reused flutter_tools code for parsing. You can check it out now

@pdenert pdenert requested a review from mateuszwojtczak June 20, 2024 13:00
Copy link
Collaborator

Choose a reason for hiding this comment

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

Won't this test cause all workflows with patrol tests in our repository to fail? I think we should exclude this test from all of them

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. Need to manage that

Copy link
Contributor

@mateuszwojtczak mateuszwojtczak left a comment

Choose a reason for hiding this comment

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

Great, one last thing - if we allow for .env style files, let's have at least one test about it

@pdenert
Copy link
Collaborator Author

pdenert commented Jun 21, 2024

Great, one last thing - if we allow for .env style files, let's have at least one test about it

Done @mateuszwojtczak

@pdenert pdenert requested a review from mateuszwojtczak June 21, 2024 10:47
Copy link
Contributor

@mateuszwojtczak mateuszwojtczak left a comment

Choose a reason for hiding this comment

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

LGTM

@pdenert pdenert merged commit 7339901 into master Jun 24, 2024
7 of 9 checks passed
@pdenert pdenert deleted the add-dart-define-from-file branch June 24, 2024 09:00

if (dartDefines.isNotEmpty) {
dartDefines.forEach((key, value) {
modified[key] = value as String;
Copy link
Contributor

Choose a reason for hiding this comment

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

@pdenert
I tried this change in our project and realized that not everything is in the form of strings, so the code crashes here - I suspect that other projects may have a similar problem

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. Can you create issue for that? We will try to address this ASAP

Copy link
Contributor

Choose a reason for hiding this comment

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

Done #2242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: patrol_cli Related to the patrol_cli package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Patrol CLI doesn't support --dart-define-from-file
4 participants