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

CC-1318 Add support for the --previous flag for the test command #33

Merged
merged 8 commits into from
Jul 3, 2024

Conversation

libmartinito
Copy link
Contributor

No description provided.

Copy link

linear bot commented Jun 20, 2024

@libmartinito libmartinito requested a review from rohitpaulk June 20, 2024 14:45
$ codecrafters test # Run tests without committing changes
$ codecrafters submit # Commit changes & submit to move to next step
$ codecrafters test # Run tests without committing changes
$ codecrafters test --previous # Run tests for the current stage and all previous stages in ascending order
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$ codecrafters test --previous # Run tests for the current stage and all previous stages in ascending order
$ codecrafters test --previous # Run tests for previous stages without committing changes

Let's just say this for now - in the future we'll change the actual behaviour to match this.


COMMANDS
test: Run tests without committing changes

Flags for test:
--previous Run tests for the current stage and all previous stages in ascending order
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the flags section from here for now - will think about how to do proper flags per command. We need a better system for this - something like codecrafters test --help.

@@ -76,7 +81,11 @@ func run() error {

switch cmd {
case "test":
return commands.TestCommand(ctx)
testCmd := flag.NewFlagSet("test", flag.ExitOnError)
previous := testCmd.Bool("previous", false, "run tests for the current stage and all previous stages in ascending order")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
previous := testCmd.Bool("previous", false, "run tests for the current stage and all previous stages in ascending order")
shouldTestPrevious := testCmd.Bool("previous", false, "run tests for the current stage and all previous stages in ascending order")

return commands.TestCommand(ctx)
testCmd := flag.NewFlagSet("test", flag.ExitOnError)
previous := testCmd.Bool("previous", false, "run tests for the current stage and all previous stages in ascending order")
testCmd.Parse(flag.Args()[1:]) // parse the args after the test command
Copy link
Member

Choose a reason for hiding this comment

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

Just curious - what happens if a user makes a typo here? If they do codecrafters test --previos for example? Will this complain? (Ideally it should)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Screenshot 2024-06-25 at 6 37 02 PM

tried it out and it does complain if a nonexistent flag is used for test

"stage_selection_strategy": "current_and_previous_descending",
}

if previous {
Copy link
Member

Choose a reason for hiding this comment

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

This decision should be one layer above, in the caller. A "client" for core shouldn't be aware of anything other than what core supports. We should accept stageSelectionStrategy here, and have the caller decide what value to pass in.

Copy link
Member

@rohitpaulk rohitpaulk left a comment

Choose a reason for hiding this comment

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

Added q

@libmartinito libmartinito dismissed rohitpaulk’s stale review June 25, 2024 15:10

applied review comments

@libmartinito libmartinito requested a review from rohitpaulk June 25, 2024 15:18
$ codecrafters test # Run tests without committing changes
$ codecrafters submit # Commit changes & submit to move to next step
$ codecrafters test # Run tests without committing changes
$ codecrafters test --previous # Run tests for the current stage and all previous stages without comitting changes
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$ codecrafters test --previous # Run tests for the current stage and all previous stages without comitting changes
$ codecrafters test --previous # Run tests for the current stage and all previous stages without committing changes

@libmartinito libmartinito merged commit 4e2c31d into main Jul 3, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants