Skip to content

Fix flipped argument state #12005

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

Merged
merged 1 commit into from
Sep 29, 2017

Conversation

Rostepher
Copy link
Contributor

@Rostepher Rostepher commented Sep 19, 2017

Purpose

This PR resolves issue SR-5911. My previous PR #11952 changed the internal 'destinations' for all the --skip-build-* and --skip-test-* flags from the form skip_build_* and skip_test_* to the affirmative build_* and test_*. When swapping those states I failed to account for the more advanced optional boolean behavior on each of these skip flags. It is possible for many flags to accept an optional boolean state to toggle them on or off manually, with skip flags it can be rather confusing since --skip-build-benchmarks True means that we should not build benchmarks. Before this fix the optional boolean was being directly set on these new inverted destinations, thus --skip-build-benchmarks True was setting the destination build_benchmarks to True rather than the expected False.

In addition to fixing the erroneous behavior I've also taken the liberty to revamp the testing suite again making a more clear distinction between flags that accept optional booleans, those that only toggle the state True or False and those that store constant values. The test suite now covers all these cases and has more strict testing for their edge cases.

A small note for reviewers, there's a lot of noise in the testing suite dealing with parsing arguments. To accurately test that each flag accepts the expected argument values and acts accordingly it was necessary to be able to parse flags without applying the defaults. Thus there's now the methods parse_args and parse_default_args on the main test case class.

rdar://34526897

@Rostepher Rostepher added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. enhancement labels Sep 19, 2017
@Rostepher Rostepher changed the title Updated argument parsing code to use a new OnOffAction with Enable an… Fix flipped argument state Sep 19, 2017
@Rostepher Rostepher force-pushed the fix-flipped-argument-state branch from 66ce0da to 56c3d8d Compare September 19, 2017 20:21
@Rostepher
Copy link
Contributor Author

@gottesmm Would you mind giving this a quick once-over before I merge?

@@ -194,6 +194,7 @@ def _apply_default_arguments(args):

# If none of tests specified skip swift stdlib test on all platforms
if not args.test and not args.validation_test and not args.long_test:
print('not testing')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whoops, left in a print statement. I'll remove that.

@gottesmm
Copy link
Contributor

@Rostepher give me a little bit. I am in some meetings today = (.

@Rostepher
Copy link
Contributor Author

@gottesmm No problem, just let me know when you've had a chance to look at it. Thanks!

@Rostepher
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Contributor

@gottesmm gottesmm left a comment

Choose a reason for hiding this comment

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

A few remarks. Also can you split out the sorting/etc into a different commit. This should be just about fixing the specific bug. If you want to change the order/layout of things please do that in a different commit so that I can review only the important things via the diff.

if parsed and defaulting to False otherwise.
"""

pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Question. Is pass supposed to be on this line according to flake8? I thought it was supposed to be right after the """

@@ -260,7 +293,7 @@ class UnsupportedOption(_BaseOption):
"""Option that is not supported."""

def __init__(self, *args, **kwargs):
kwargs['dest'] = kwargs.pop('dest', None)
kwargs['dest'] = kwargs.get('dest', None)
Copy link
Contributor

Choose a reason for hiding this comment

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

I still hate this. Can you just do this:

if 'dest' not in kwargs:
    kwargs['dest'] = None

@@ -270,7 +303,9 @@ class IgnoreOption(_BaseOption):
generated.
"""

pass
def __init__(self, *args, **kwargs):
kwargs['dest'] = kwargs.get('dest', None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

pass


class EnableOption(_BaseOption):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you leave any shuffling to a different commit. This is going to be difficult to review.

@gottesmm
Copy link
Contributor

With my review, I stopped due to the moving around of code. Please fix that and then I will relook.

@Rostepher Rostepher force-pushed the fix-flipped-argument-state branch from 710a5a2 to 9b672e8 Compare September 25, 2017 02:42
@shahmishal
Copy link
Member

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 66ce0dae13ac721b6d6d2af0bb31c8a7c9ab1c90

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - 66ce0dae13ac721b6d6d2af0bb31c8a7c9ab1c90

@shahmishal
Copy link
Member

@swift-ci test Linux

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 9b672e8516b0438d09b655498d429b6ceebd3fa4

@Rostepher Rostepher force-pushed the fix-flipped-argument-state branch from 9b672e8 to 3d33634 Compare September 26, 2017 21:35
@Rostepher
Copy link
Contributor Author

@swift-ci please smoke test

@Rostepher
Copy link
Contributor Author

@swift-ci please test

@swiftlang swiftlang deleted a comment from swift-ci Sep 26, 2017
@swiftlang swiftlang deleted a comment from swift-ci Sep 26, 2017
…d Disable variants, properly handling optional boolean arguments and inverting the state for disabled options. Previously when an option such as '--skip-build-benchmarks' was passed with a boolean the destination would take on the value without inverting the state, which was causing some build configuration errors.
@Rostepher Rostepher force-pushed the fix-flipped-argument-state branch from 3d33634 to edb4daf Compare September 26, 2017 23:22
@Rostepher
Copy link
Contributor Author

@swift-ci please smoke test

@Rostepher
Copy link
Contributor Author

@gottesmm Would you mind taking a look over this fix again. I've removed the test changes for now. I'll add those in a follow-up PR, I'd rather get this merged first to avoid any unexpected regressions.

@lplarson
Copy link
Contributor

LGTM

@Rostepher Rostepher merged commit d1620f5 into swiftlang:master Sep 29, 2017
@Rostepher Rostepher deleted the fix-flipped-argument-state branch September 29, 2017 19:06
@AnthonyLatsis AnthonyLatsis added bug fix improvement and removed bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. enhancement labels Nov 13, 2022
@AnthonyLatsis AnthonyLatsis added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. and removed bug fix labels Apr 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants