Skip to content

Commit f8af1de

Browse files
committed
test: Replace help text integration tests with insta snapshots
The prysk integration tests for CLI help text (turbo-help.t at 540 lines, plus ~120 lines in no-args.t) required manually updating hundreds of lines of inline expected output whenever any CLI option changed. Replace them with 6 insta snapshot tests that can be updated with `cargo insta review`.
1 parent 0f22994 commit f8af1de

9 files changed

+441
-662
lines changed

crates/turborepo-lib/src/cli/mod.rs

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1718,13 +1718,68 @@ mod test {
17181718
use std::{assert_matches::assert_matches, ffi::OsString};
17191719

17201720
use camino::Utf8PathBuf;
1721-
use clap::Parser;
1721+
use clap::{CommandFactory, Parser};
17221722
use insta::assert_snapshot;
17231723
use itertools::Itertools;
17241724
use pretty_assertions::assert_eq;
17251725

17261726
use crate::cli::{ContinueMode, ExecutionArgs, LinkTarget, RunArgs};
17271727

1728+
fn get_subcommand(name: &str) -> clap::Command {
1729+
Args::command()
1730+
.find_subcommand(name)
1731+
.unwrap_or_else(|| panic!("subcommand '{name}' not found"))
1732+
.clone()
1733+
}
1734+
1735+
#[test]
1736+
fn turbo_short_help() {
1737+
let mut cmd = Args::command();
1738+
let mut buf = Vec::new();
1739+
cmd.write_help(&mut buf).unwrap();
1740+
assert_snapshot!(String::from_utf8(buf).unwrap());
1741+
}
1742+
1743+
#[test]
1744+
fn turbo_long_help() {
1745+
let mut cmd = Args::command();
1746+
let mut buf = Vec::new();
1747+
cmd.write_long_help(&mut buf).unwrap();
1748+
assert_snapshot!(String::from_utf8(buf).unwrap());
1749+
}
1750+
1751+
#[test]
1752+
fn link_short_help() {
1753+
let mut cmd = get_subcommand("link");
1754+
let mut buf = Vec::new();
1755+
cmd.write_help(&mut buf).unwrap();
1756+
assert_snapshot!(String::from_utf8(buf).unwrap());
1757+
}
1758+
1759+
#[test]
1760+
fn unlink_short_help() {
1761+
let mut cmd = get_subcommand("unlink");
1762+
let mut buf = Vec::new();
1763+
cmd.write_help(&mut buf).unwrap();
1764+
assert_snapshot!(String::from_utf8(buf).unwrap());
1765+
}
1766+
1767+
#[test]
1768+
fn login_short_help() {
1769+
let mut cmd = get_subcommand("login");
1770+
let mut buf = Vec::new();
1771+
cmd.write_help(&mut buf).unwrap();
1772+
assert_snapshot!(String::from_utf8(buf).unwrap());
1773+
}
1774+
1775+
#[test]
1776+
fn logout_short_help() {
1777+
let mut cmd = get_subcommand("logout");
1778+
let mut buf = Vec::new();
1779+
cmd.write_help(&mut buf).unwrap();
1780+
assert_snapshot!(String::from_utf8(buf).unwrap());
1781+
}
1782+
17281783
struct CommandTestCase {
17291784
command: &'static str,
17301785
command_args: Vec<Vec<&'static str>>,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
source: crates/turborepo-lib/src/cli/mod.rs
3+
expression: "String::from_utf8(buf).unwrap()"
4+
---
5+
Link your local directory to a Vercel organization and enable remote caching
6+
7+
Usage: link [OPTIONS]
8+
9+
Options:
10+
--no-gitignore Do not create or modify .gitignore (default false)
11+
--scope <SCOPE> The scope, i.e. Vercel team, to which you are linking
12+
-y, --yes Answer yes to all prompts (default false)
13+
--target <TARGET> DEPRECATED: Specify what should be linked (default "remote cache") [possible values: remote-cache, spaces]
14+
-h, --help Print help
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
source: crates/turborepo-lib/src/cli/mod.rs
3+
expression: "String::from_utf8(buf).unwrap()"
4+
---
5+
Login to your Vercel account
6+
7+
Usage: login [OPTIONS]
8+
9+
Options:
10+
--sso-team <SSO_TEAM>
11+
-f, --force Force a login to receive a new token. Will overwrite any existing tokens for the given login url
12+
--manual Manually enter token instead of requesting one from the login service
13+
-h, --help Print help
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: crates/turborepo-lib/src/cli/mod.rs
3+
expression: "String::from_utf8(buf).unwrap()"
4+
---
5+
Logout to your Vercel account
6+
7+
Usage: logout [OPTIONS]
8+
9+
Options:
10+
--invalidate Invalidate the token on the server
11+
-h, --help Print help
Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
---
2+
source: crates/turborepo-lib/src/cli/mod.rs
3+
expression: "String::from_utf8(buf).unwrap()"
4+
---
5+
The build system that makes ship happen
6+
7+
Usage: turbo [OPTIONS] [COMMAND]
8+
9+
Commands:
10+
bin Get the path to the Turbo binary
11+
get-mfe-port Get the port assigned to the current microfrontend
12+
completion Generate the autocompletion script for the specified shell
13+
daemon Runs the Turborepo background daemon
14+
devtools Visualize your monorepo's package graph in the browser
15+
docs Search the Turborepo documentation
16+
generate Generate a new app / package
17+
telemetry Enable or disable anonymous telemetry
18+
scan Turbo your monorepo by running a number of 'repo lints' to identify common issues, suggest fixes, and improve performance
19+
ls EXPERIMENTAL: List packages in your monorepo
20+
link Link your local directory to a Vercel organization and enable remote caching
21+
login Login to your Vercel account
22+
logout Logout to your Vercel account
23+
info Print debugging information
24+
prune Prepare a subset of your monorepo
25+
run Run tasks across projects in your monorepo
26+
query Query your monorepo using GraphQL. If no query is provided, spins up a GraphQL server with GraphiQL
27+
watch Arguments used in run and watch
28+
unlink Unlink the current directory from your Vercel organization and disable Remote Caching
29+
30+
Options:
31+
--version
32+
33+
34+
--skip-infer
35+
Skip any attempts to infer which version of Turbo the project is configured to use
36+
37+
--no-update-notifier
38+
Disable the turbo update notification
39+
40+
--api <API>
41+
Override the endpoint for API calls
42+
43+
--color
44+
Force color usage in the terminal
45+
46+
--cwd <CWD>
47+
The directory in which to run turbo
48+
49+
--heap <HEAP>
50+
Specify a file to save a pprof heap profile
51+
52+
--ui <UI>
53+
Specify whether to use the streaming UI or TUI
54+
55+
Possible values:
56+
- tui: Use the terminal user interface
57+
- stream: Use the standard output stream
58+
- stream-with-experimental-timestamps: Use the standard output stream with timestamps. Note: This feature is experimental and may change or be removed at any time
59+
- web: Use the web user interface. Note: This feature is undocumented, experimental, and not meant to be used. It may change or be removed at any time
60+
61+
--login <LOGIN>
62+
Override the login endpoint
63+
64+
--no-color
65+
Suppress color usage in the terminal
66+
67+
--preflight
68+
When enabled, turbo will precede HTTP requests with an OPTIONS request for authorization
69+
70+
--remote-cache-timeout <TIMEOUT>
71+
Set a timeout for all HTTP requests
72+
73+
--team <TEAM>
74+
Set the team slug for API calls
75+
76+
--token <TOKEN>
77+
Set the auth token for API calls
78+
79+
--trace <TRACE>
80+
Specify a file to save a pprof trace
81+
82+
--verbosity <COUNT>
83+
Verbosity level. Useful when debugging Turborepo or creating logs for issue reports
84+
85+
--dangerously-disable-package-manager-check
86+
Allow for missing `packageManager` in `package.json`.
87+
88+
`turbo` will use hints from codebase to guess which package manager should be used.
89+
90+
--root-turbo-json <ROOT_TURBO_JSON>
91+
Use the `turbo.json` located at the provided path instead of one at the root of the repository
92+
93+
-h, --help
94+
Print help (see a summary with '-h')
95+
96+
Run Arguments:
97+
--cache <CACHE>
98+
Set the cache behavior for this run. Pass a list of comma-separated key, value pairs to enable reading and writing to either the local or remote cache
99+
100+
--force [<FORCE>]
101+
Ignore the existing cache (to force execution). Equivalent to `--cache=local:w,remote:w`
102+
103+
[possible values: true, false]
104+
105+
--remote-only [<REMOTE_ONLY>]
106+
Ignore the local filesystem cache for all tasks. Only allow reading and caching artifacts using the remote cache. Equivalent to `--cache=remote:rw`
107+
108+
[possible values: true, false]
109+
110+
--remote-cache-read-only [<REMOTE_CACHE_READ_ONLY>]
111+
Treat remote cache as read only. Equivalent to `--cache=remote:r;local:rw`
112+
113+
[possible values: true, false]
114+
115+
--no-cache
116+
Avoid saving task results to the cache. Useful for development/watch tasks. Equivalent to `--cache=local:r,remote:r`
117+
118+
--cache-workers <CACHE_WORKERS>
119+
Set the number of concurrent cache operations (default 10)
120+
121+
[default: 10]
122+
123+
--dry-run [<DRY_RUN>]
124+
[possible values: text, json]
125+
126+
--graph [<GRAPH>]
127+
Generate a graph of the task execution and output to a file when a filename is specified (.svg, .png, .jpg, .pdf, .json, .html, .mermaid, .dot). Outputs dot graph to stdout when if no filename is provided
128+
129+
--daemon
130+
[DEPRECATED] The daemon is no longer used for `turbo run`. This flag will be removed in version 3.0
131+
132+
--no-daemon
133+
[DEPRECATED] The daemon is no longer used for `turbo run`. This flag will be removed in version 3.0
134+
135+
--profile [<PROFILE>]
136+
File to write turbo's performance profile output into. You can load the file up in chrome://tracing to see which parts of your build were slow
137+
138+
--anon-profile [<ANON_PROFILE>]
139+
File to write turbo's performance profile output into. All identifying data omitted from the profile
140+
141+
--summarize [<SUMMARIZE>]
142+
Generate a summary of the turbo run
143+
144+
[possible values: true, false]
145+
146+
--parallel
147+
Execute all tasks in parallel
148+
149+
--cache-dir <CACHE_DIR>
150+
Override the filesystem cache directory
151+
152+
--concurrency <CONCURRENCY>
153+
Limit the concurrency of task execution. Use 1 for serial (i.e. one-at-a-time) execution
154+
155+
--continue[=<CONTINUE>]
156+
Specify how task execution should proceed when an error occurs. Use "never" to cancel all tasks. Use "dependencies-successful" to continue running tasks whose dependencies have succeeded. Use "always" to continue running all tasks, even those whose dependencies have failed
157+
158+
[default: never]
159+
[possible values: never, dependencies-successful, always]
160+
161+
--single-package
162+
Run turbo in single-package mode
163+
164+
--framework-inference [<BOOL>]
165+
Specify whether or not to do framework inference for tasks
166+
167+
[default: true]
168+
[possible values: true, false]
169+
170+
--global-deps <GLOBAL_DEPS>
171+
Specify glob of global filesystem dependencies to be hashed. Useful for .env and files
172+
173+
--env-mode [<ENV_MODE>]
174+
Environment variable mode. Use "loose" to pass the entire existing environment. Use "strict" to use an allowlist specified in turbo.json
175+
176+
Possible values:
177+
- loose: Allow all environment variables for the process to be available
178+
- strict: Filter environment variables to only those that are specified in the `env` and `globalEnv` keys in `turbo.json`
179+
180+
-F, --filter <FILTER>
181+
Use the given selector to specify package(s) to act as entry points. The syntax mirrors pnpm's syntax, and additional documentation and examples can be found in turbo's documentation https://turborepo.dev/docs/reference/command-line-reference/run#--filter
182+
183+
--affected
184+
Filter to only packages that are affected by changes between the current branch and `main`
185+
186+
--output-logs <OUTPUT_LOGS>
187+
Set type of process output logging. Use "full" to show all output. Use "hash-only" to show only turbo-computed task hashes. Use "new-only" to show only new output with only hashes for cached tasks. Use "none" to hide process output. (default full)
188+
189+
Possible values:
190+
- full: Displays all output
191+
- none: Hides all task output
192+
- hash-only: Show only the hashes of the tasks
193+
- new-only: Only show output from cache misses
194+
- errors-only: Only show output from task failures
195+
196+
--log-order <LOG_ORDER>
197+
Set type of task output order. Use "stream" to show output as soon as it is available. Use "grouped" to show output when a command has finished execution. Use "auto" to let turbo decide based on its own heuristics. (default auto)
198+
199+
[possible values: auto, stream, grouped]
200+
201+
--only
202+
Only executes the tasks specified, does not execute parent tasks
203+
204+
--log-prefix <LOG_PREFIX>
205+
Use "none" to remove prefixes from task logs. Use "task" to get task id prefixing. Use "auto" to let turbo decide how to prefix the logs based on the execution environment. In most cases this will be the same as "task". Note that tasks running in parallel interleave their logs, so removing prefixes can make it difficult to associate logs with tasks. Use --log-order=grouped to prevent interleaving. (default auto)
206+
207+
[default: auto]
208+
[possible values: auto, none, task]

0 commit comments

Comments
 (0)