这是indexloc提供的服务,不要输入任何密码
Skip to content

tests(turbo): Rust CLI Tests #2379

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 6 commits into from
Oct 27, 2022

Conversation

NicholasLYang
Copy link
Contributor

Adding tests for both CLI parsing and e2e.

@NicholasLYang NicholasLYang requested a review from a team as a code owner October 26, 2022 16:41
@vercel
Copy link

vercel bot commented Oct 26, 2022

@NicholasLYang is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
Copy link

vercel bot commented Oct 26, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

5 Ignored Deployments
Name Status Preview Updated
examples-basic-web ⬜️ Ignored (Inspect) Oct 27, 2022 at 8:38PM (UTC)
examples-designsystem-docs ⬜️ Ignored (Inspect) Oct 27, 2022 at 8:38PM (UTC)
examples-kitchensink-blog ⬜️ Ignored (Inspect) Oct 27, 2022 at 8:38PM (UTC)
examples-native-web ⬜️ Ignored (Inspect) Oct 27, 2022 at 8:38PM (UTC)
examples-svelte-web ⬜️ Ignored (Inspect) Oct 27, 2022 at 8:38PM (UTC)

Copy link
Contributor

@mehulkar mehulkar left a comment

Choose a reason for hiding this comment

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

Question about Rust but otherwise looks like an improvement!

..Args::default()
},
}
.test();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is it convention to put all rust tests in the same file (as opposed to .test.rs or something? Feels pretty noisy/distracting to have this here

Copy link
Contributor

Choose a reason for hiding this comment

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

I see shim/tests/mod.rs. What's the difference between those tests and these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a difference of integration versus unit tests. These are tests that require internal data structures like Args that we wouldn't have access to in tests/. I agree that this file is starting to get unwieldy though. Might split it up and put the repo state code in its own file.

@mehulkar
Copy link
Contributor

Also, do we need a GH workflow to run these tests or does that already exist somewhere?

Copy link
Member

@chris-olszewski chris-olszewski left a comment

Choose a reason for hiding this comment

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

Biggest concern is that we're not testing commands that have global args in a position other than right after turbo

@@ -1,5 +1,69 @@
use assert_cmd::Command;

static TURBO_HELP: &str = "turbo
Copy link
Member

Choose a reason for hiding this comment

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

Commented on #2386, but I generally prefer to keep UI snapshot tests in something like cram/prysk that has better support for updating snapshots support for diffing snapshots.

}
}

fn create_all_arg_permutations(&self) -> Vec<Vec<&'static str>> {
Copy link
Member

Choose a reason for hiding this comment

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

Should we also be testing interspersing global args with the command args? If I'm reading this correctly we're only putting global args right after turbo. IIRC correctly cobra allows for these args to appear anywhere which is a behavior we want to keep.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the algorithm tests all permutations of the global args with the command, so for [[ "login" ], [ "--cwd ../example/basic"]] it tests:

[[ "login" ], [ "--cwd ../example/basic"]]
[[ "--cwd ../example/basic"], [ "login" ]]

I added the command for the global arg permutations for the exact reason you stated; this lets us test the global arguments both before and after the subcommand. It does however mean that we only place sub-command arguments after the global arguments, but I think that's good enough.

@NicholasLYang NicholasLYang added the pr: automerge Kodiak will merge these automatically after checks pass label Oct 27, 2022
@NicholasLYang NicholasLYang merged commit e4006da into vercel:main Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: automerge Kodiak will merge these automatically after checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants