Skip to content

Conversation

@EArminjon
Copy link
Contributor

@EArminjon EArminjon commented Dec 8, 2022

This PR intent to add the possibility for developer which have a heavy project, to run flutter clean with a specific scheme. This to avoid running xcode clean to all schemes.

List which issues are fixed by this PR. You must list at least one issue.
#116735

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.
Done

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Dec 8, 2022
Copy link
Contributor Author

@EArminjon EArminjon Dec 8, 2022

Choose a reason for hiding this comment

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

(Will remove)

Actually displaying null...

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see null when I run this locally. Are you ensuring the cached tool snapshot is up to date? See https://github.com/flutter/flutter/wiki/The-flutter-tool#making-changes-to-the-flutter-tool for more context.

Copy link
Contributor Author

@EArminjon EArminjon Dec 9, 2022

Choose a reason for hiding this comment

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

will check that.

Currently i run my unit test with this command :

$>  dart bin/flutter_tools.dart test test/commands.shard/hermetic/clean_test.dart

Copy link
Contributor

Choose a reason for hiding this comment

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

will check that.

Currently i run my unit test with this command :

$>  dart bin/flutter_tools.dart test test/commands.shard/hermetic/clean_test.dart

Well if it's showing null in unit tests, that's different :) That means your test is set up wrong.

Copy link
Contributor Author

@EArminjon EArminjon Dec 12, 2022

Choose a reason for hiding this comment

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

will check that.
Currently i run my unit test with this command :

$>  dart bin/flutter_tools.dart test test/commands.shard/hermetic/clean_test.dart

Well if it's showing null in unit tests, that's different :) That means your test is set up wrong.

Need help on that, didn't know what is wrong inside the test... Just trying to use my flag inside test...

Copy link
Contributor Author

@EArminjon EArminjon Dec 12, 2022

Choose a reason for hiding this comment

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

I pushed a new version with a working test. Maybe not the best test ever, do not hesitate to tell me what changes need I do.

@EArminjon EArminjon force-pushed the feature/clean-a-specific-scheme branch 3 times, most recently from 68ea985 to 77724ac Compare December 12, 2022 11:27
@EArminjon EArminjon changed the title draft: feature/clean-a-specific-scheme: Add this-scheme new flag for clean c… feature/clean-a-specific-scheme: Add this-scheme new flag for clean c… Dec 12, 2022
@andrewkolos
Copy link
Contributor

Thanks for the PR!

I checked out this branch and tried to use the new option, and I got some interesting results:

andrewkolos-macbookpro:simple_asset_issues andrewkolos$ flutter clean this-scheme=this_is_not_a_real_scheme
Cleaning Xcode workspace...                                      1,529ms
Cleaning Xcode workspace...                                      2,147ms
andrewkolos-macbookpro:simple_asset_issues andrewkolos$ flutter clean this-scheme
Cleaning Xcode workspace...                                      1,458ms
Cleaning Xcode workspace...                                      2,184ms

As you see, the command appeared to run without issue despite 1) receiving a name for a non-existent scheme and 2) not being given a scheme at all. This isn't intended, right?

I verified that this-scheme appeares in the output of flutter clean -h, so I believe I'm using the right version of flutter.

On an unrelated note: for the CLI argument name, I would consider using scheme instead of this-scheme. scheme would be more like what CLI args typically look like. The this- strikes me as redundant.

@EArminjon EArminjon force-pushed the feature/clean-a-specific-scheme branch from 77724ac to ac500c4 Compare December 16, 2022 09:34
@EArminjon
Copy link
Contributor Author

EArminjon commented Dec 16, 2022

Thanks for the PR!

I checked out this branch and tried to use the new option, and I got some interesting results:

andrewkolos-macbookpro:simple_asset_issues andrewkolos$ flutter clean this-scheme=this_is_not_a_real_scheme
Cleaning Xcode workspace...                                      1,529ms
Cleaning Xcode workspace...                                      2,147ms
andrewkolos-macbookpro:simple_asset_issues andrewkolos$ flutter clean this-scheme
Cleaning Xcode workspace...                                      1,458ms
Cleaning Xcode workspace...                                      2,184ms

As you see, the command appeared to run without issue despite 1) receiving a name for a non-existent scheme and 2) not being given a scheme at all. This isn't intended, right?

I verified that this-scheme appeares in the output of flutter clean -h, so I believe I'm using the right version of flutter.

On an unrelated note: for the CLI argument name, I would consider using scheme instead of this-scheme. scheme would be more like what CLI args typically look like. The this- strikes me as redundant.

I will rework error management. Btw, command was "--this-scheme" not "this-scheme".

Copy link
Contributor Author

@EArminjon EArminjon Dec 16, 2022

Choose a reason for hiding this comment

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

Exceptions here were hidden. If xcode didn't find scheme or throw something it's important to abort no ? I've edited that.

Copy link
Contributor

Choose a reason for hiding this comment

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

@christopherfujino Do you have any opinions on this? In particular, is it appropriate to throw a ToolExit in the case of input error (i.e. no scheme given)?

Copy link
Contributor

Choose a reason for hiding this comment

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

@christopherfujino Do you have any opinions on this? In particular, is it appropriate to throw a ToolExit in the case of input error (i.e. no scheme given)?

I'm not sure I understand the question. Are you asking if we should printError and exit 0 when the user provides a non-existent scheme? If so, then I think tool exiting is the right course of action (ToolExit generally means that we cannot continue because of some invalid state, usually based on user inputs).

If I'm misunderstanding the question, please clarify.

Copy link
Contributor

Choose a reason for hiding this comment

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

Three new ToolExit throws are added here:

https://github.com/flutter/flutter/blob/8c7682a933a9fb856631706da2e9e1fb49bf1d18/packages/flutter_tools/lib/src/commands/clean.dart#L91-L96

and

https://github.com/flutter/flutter/blob/8c7682a933a9fb856631706da2e9e1fb49bf1d18/packages/flutter_tools/lib/src/commands/clean.dart#L103-L105

(side note: the first two shown in the first code snippet will get caught by the catch in the second code snippet, in which case a different ToolExit is thrown)

However, in other cases throughout the tool, debug.printError is used without throwing a ToolExit. Example:

} on FileSystemException catch (err) {
globals.printError('Cannot clean ${file.path}.\n$err');
return;
}

Going back to the three newly added ToolExit throws, is it appropriate to throw here instead of just printing an error message? Asked more specifically:

  1. Is it appropriate to throw if a user provides an invalid Xcode scheme name (or doesn't provide one at all despite using --scheme), or should we print an error message and continue with cleaning?
  2. Is it appropriate to throw if something goes wrong with cleaning a workspace, or should we print an error message and continue with cleaning?

Copy link
Contributor

Choose a reason for hiding this comment

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

Three new ToolExit throws are added here:

https://github.com/flutter/flutter/blob/8c7682a933a9fb856631706da2e9e1fb49bf1d18/packages/flutter_tools/lib/src/commands/clean.dart#L91-L96

and

https://github.com/flutter/flutter/blob/8c7682a933a9fb856631706da2e9e1fb49bf1d18/packages/flutter_tools/lib/src/commands/clean.dart#L103-L105

(side note: the first two shown in the first code snippet will get caught by the catch in the second code snippet, in which case a different ToolExit is thrown)

However, in other cases throughout the tool, debug.printError is used without throwing a ToolExit. Example:

} on FileSystemException catch (err) {
globals.printError('Cannot clean ${file.path}.\n$err');
return;
}

Going back to the three newly added ToolExit throws, is it appropriate to throw here instead of just printing an error message? Asked more specifically:

  1. Is it appropriate to throw if a user provides an invalid Xcode scheme name (or doesn't provide one at all despite using --scheme), or should we print an error message and continue with cleaning?

This to me seems like a clear user error, and thus should be a tool exit.

  1. Is it appropriate to throw if something goes wrong with cleaning a workspace, or should we print an error message and continue with cleaning?

It makes sense to me printError and continue cleaning, but I don't have a strong opinion either way.

@christopherfujino
Copy link
Contributor

@andrewkolos can you take another look at this one?

@christopherfujino
Copy link
Contributor

@andrewkolos friendly ping

@andrewkolos
Copy link
Contributor

Hello--sorry I lost track of this PR, I confused it with another one that was merged. I'll be looking at this again shortly

@andrewkolos
Copy link
Contributor

Is this ready for review again?

@EArminjon
Copy link
Contributor Author

Is this ready for review again?

Yes

@andrewkolos
Copy link
Contributor

@EArminjon Google testing seems to be stuck for this PR. Would you mind merging upstream/master into this branch? This might fix it.

@EArminjon
Copy link
Contributor Author

oops bad push, will fix

@EArminjon EArminjon force-pushed the feature/clean-a-specific-scheme branch from ca77e23 to a4a9b68 Compare February 8, 2023 08:52
@EArminjon
Copy link
Contributor Author

Seems to be good now.

@andrewkolos
Copy link
Contributor

The ci.yaml validation check is failing for some reason. Per the message, could you try another git fetch upstream && git merge upstream/master?

@EArminjon EArminjon force-pushed the feature/clean-a-specific-scheme branch from 27f7eac to b49b561 Compare February 10, 2023 08:28
@EArminjon EArminjon closed this Feb 10, 2023
@EArminjon EArminjon force-pushed the feature/clean-a-specific-scheme branch from b49b561 to e6ec087 Compare February 10, 2023 08:38
@EArminjon EArminjon reopened this Feb 10, 2023
@EArminjon
Copy link
Contributor Author

(didn't know why I always fail my rebase. I update my repo on github to sync it with the original flutter repo. Then i go to my branch : git fetch --all && git pull --rebase origin master && git push origin my_branch_name -f. I got the all commit history pushed... Git is still a subject for me despite all these years...)

Must be good this time :'( !

Copy link
Contributor

@andrewkolos andrewkolos left a comment

Choose a reason for hiding this comment

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

LGTM

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 22, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 22, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 23, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 23, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 23, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 24, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 25, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 25, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 26, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 26, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 26, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 27, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants