Skip to content

Commit

Permalink
Added tests for passing correct config
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang committed Apr 21, 2023
1 parent 9334218 commit f625f4e
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/cli.rs
Expand Up @@ -533,7 +533,7 @@ pub async fn run(repo_state: Option<RepoState>) -> Result<Payload> {

if let Err(err) = link::link(&mut base, modify_gitignore, to).await {
error!("error: {}", err.to_string())
};
}

Ok(Payload::Rust(Ok(0)))
}
Expand Down
1 change: 0 additions & 1 deletion crates/turborepo-lib/src/execution_state.rs
Expand Up @@ -36,4 +36,3 @@ impl<'a> TryFrom<&'a CommandBase> for ExecutionState<'a> {
})
}
}

6 changes: 6 additions & 0 deletions crates/turborepo/src/main.rs
Expand Up @@ -41,6 +41,12 @@ fn run_go_binary(execution_state: ExecutionState) -> Result<i32> {
));
}

if execution_state.cli_args.test_run {
let serialized_args = serde_json::to_string_pretty(&execution_state)?;
println!("Invoking go binary with {}", serialized_args);
return Ok(0);
}

let serialized_args = serde_json::to_string(&execution_state)?;
trace!("Invoking go binary with {}", serialized_args);
let mut command = process::Command::new(go_binary_path);
Expand Down
333 changes: 333 additions & 0 deletions turborepo-tests/integration/tests/config.t
@@ -0,0 +1,333 @@
Setup
$ . ${TESTDIR}/../../helpers/setup.sh
$ . ${TESTDIR}/_helpers/setup_monorepo.sh $(pwd)

Run test run
$ ${TURBO} run build --__test-run
Invoking go binary with {
"remote_config": {
"token": null,
"team_id": null,
"team_slug": null,
"api_url": "https://vercel.com/api"
},
"cli_args": {
"version": false,
"no_update_notifier": false,
"api": null,
"color": false,
"cpu_profile": null,
"cwd": ".*", (re)
"heap": null,
"login": null,
"no_color": false,
"preflight": false,
"remote_cache_timeout": null,
"team": null,
"token": null,
"trace": null,
"verbosity": 0,
"check_for_update": false,
"test_run": true,
"run_args": null,
"command": {
"Run": {
"cache_dir": null,
"cache_workers": 10,
"concurrency": null,
"continue_execution": false,
"dry_run": null,
"single_package": false,
"filter": [],
"force": false,
"global_deps": [],
"graph": null,
"env_mode": "Infer",
"ignore": [],
"include_dependencies": false,
"no_cache": false,
"no_daemon": false,
"no_deps": false,
"output_logs": null,
"only": false,
"parallel": false,
"pkg_inference_root": "",
"profile": null,
"remote_only": false,
"scope": [],
"since": null,
"summarize": null,
"log_prefix": null,
"tasks": [
"build"
],
"pass_through_args": [],
"experimental_space_id": null
}
}
}
}

Run test run with api overloaded
$ ${TURBO} run build --__test-run --api http://localhost:8000
Invoking go binary with {
"remote_config": {
"token": null,
"team_id": null,
"team_slug": null,
"api_url": "http://localhost:8000"
},
"cli_args": {
"version": false,
"no_update_notifier": false,
"api": "http://localhost:8000",
"color": false,
"cpu_profile": null,
"cwd": ".*", (re)
"heap": null,
"login": null,
"no_color": false,
"preflight": false,
"remote_cache_timeout": null,
"team": null,
"token": null,
"trace": null,
"verbosity": 0,
"check_for_update": false,
"test_run": true,
"run_args": null,
"command": {
"Run": {
"cache_dir": null,
"cache_workers": 10,
"concurrency": null,
"continue_execution": false,
"dry_run": null,
"single_package": false,
"filter": [],
"force": false,
"global_deps": [],
"graph": null,
"env_mode": "Infer",
"ignore": [],
"include_dependencies": false,
"no_cache": false,
"no_daemon": false,
"no_deps": false,
"output_logs": null,
"only": false,
"parallel": false,
"pkg_inference_root": "",
"profile": null,
"remote_only": false,
"scope": [],
"since": null,
"summarize": null,
"log_prefix": null,
"tasks": [
"build"
],
"pass_through_args": [],
"experimental_space_id": null
}
}
}
}

Run test run with token overloaded
$ ${TURBO} run build --__test-run --token 1234567890
Invoking go binary with {
"remote_config": {
"token": "1234567890",
"team_id": null,
"team_slug": null,
"api_url": "https://vercel.com/api"
},
"cli_args": {
"version": false,
"no_update_notifier": false,
"api": null,
"color": false,
"cpu_profile": null,
"cwd": ".*", (re)
"heap": null,
"login": null,
"no_color": false,
"preflight": false,
"remote_cache_timeout": null,
"team": null,
"token": "1234567890",
"trace": null,
"verbosity": 0,
"check_for_update": false,
"test_run": true,
"run_args": null,
"command": {
"Run": {
"cache_dir": null,
"cache_workers": 10,
"concurrency": null,
"continue_execution": false,
"dry_run": null,
"single_package": false,
"filter": [],
"force": false,
"global_deps": [],
"graph": null,
"env_mode": "Infer",
"ignore": [],
"include_dependencies": false,
"no_cache": false,
"no_daemon": false,
"no_deps": false,
"output_logs": null,
"only": false,
"parallel": false,
"pkg_inference_root": "",
"profile": null,
"remote_only": false,
"scope": [],
"since": null,
"summarize": null,
"log_prefix": null,
"tasks": [
"build"
],
"pass_through_args": [],
"experimental_space_id": null
}
}
}
}

Run test run with team overloaded
$ ${TURBO} run build --__test-run --team vercel
Invoking go binary with {
"remote_config": {
"token": null,
"team_id": null,
"team_slug": "vercel",
"api_url": "https://vercel.com/api"
},
"cli_args": {
"version": false,
"no_update_notifier": false,
"api": null,
"color": false,
"cpu_profile": null,
"cwd": ".*", (re)
"heap": null,
"login": null,
"no_color": false,
"preflight": false,
"remote_cache_timeout": null,
"team": "vercel",
"token": null,
"trace": null,
"verbosity": 0,
"check_for_update": false,
"test_run": true,
"run_args": null,
"command": {
"Run": {
"cache_dir": null,
"cache_workers": 10,
"concurrency": null,
"continue_execution": false,
"dry_run": null,
"single_package": false,
"filter": [],
"force": false,
"global_deps": [],
"graph": null,
"env_mode": "Infer",
"ignore": [],
"include_dependencies": false,
"no_cache": false,
"no_daemon": false,
"no_deps": false,
"output_logs": null,
"only": false,
"parallel": false,
"pkg_inference_root": "",
"profile": null,
"remote_only": false,
"scope": [],
"since": null,
"summarize": null,
"log_prefix": null,
"tasks": [
"build"
],
"pass_through_args": [],
"experimental_space_id": null
}
}
}
}

Run test run with team overloaded from both env and flag (flag should take precedence)
$ TURBO_TEAM=vercel ${TURBO} run build --__test-run --team turbo
Invoking go binary with {
"remote_config": {
"token": null,
"team_id": null,
"team_slug": "turbo",
"api_url": "https://vercel.com/api"
},
"cli_args": {
"version": false,
"no_update_notifier": false,
"api": null,
"color": false,
"cpu_profile": null,
"cwd": ".*",
"heap": null,
"login": null,
"no_color": false,
"preflight": false,
"remote_cache_timeout": null,
"team": "turbo",
"token": null,
"trace": null,
"verbosity": 0,
"check_for_update": false,
"test_run": true,
"run_args": null,
"command": {
"Run": {
"cache_dir": null,
"cache_workers": 10,
"concurrency": null,
"continue_execution": false,
"dry_run": null,
"single_package": false,
"filter": [],
"force": false,
"global_deps": [],
"graph": null,
"env_mode": "Infer",
"ignore": [],
"include_dependencies": false,
"no_cache": false,
"no_daemon": false,
"no_deps": false,
"output_logs": null,
"only": false,
"parallel": false,
"pkg_inference_root": "",
"profile": null,
"remote_only": false,
"scope": [],
"since": null,
"summarize": null,
"log_prefix": null,
"tasks": [
"build"
],
"pass_through_args": [],
"experimental_space_id": null
}
}
}
}

0 comments on commit f625f4e

Please sign in to comment.