forked from astral-sh/rye
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic tools behavior test (astral-sh#707)
- Loading branch information
Showing
2 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
use std::env::consts::EXE_EXTENSION; | ||
use std::fs; | ||
|
||
use crate::common::{rye_cmd_snapshot, Space}; | ||
|
||
mod common; | ||
|
||
#[test] | ||
fn test_basic_tool_behavior() { | ||
let space = Space::new(); | ||
|
||
// in case we left things behind from last run. | ||
fs::remove_dir_all(space.rye_home().join("tools")).ok(); | ||
fs::remove_file( | ||
space | ||
.rye_home() | ||
.join("shims") | ||
.join("pycowsay") | ||
.with_extension(EXE_EXTENSION), | ||
) | ||
.ok(); | ||
|
||
rye_cmd_snapshot!( | ||
space.rye_cmd() | ||
.arg("tools") | ||
.arg("install") | ||
.arg("pycowsay") | ||
.arg("-p") | ||
.arg("[email protected]"), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
Installed scripts: | ||
- pycowsay | ||
----- stderr ----- | ||
Resolved 1 package in [EXECUTION_TIME] | ||
Downloaded 1 package in [EXECUTION_TIME] | ||
Installed 1 package in [EXECUTION_TIME] | ||
+ pycowsay==0.0.0.2 | ||
"###); | ||
|
||
rye_cmd_snapshot!( | ||
space.rye_cmd() | ||
.arg("tools") | ||
.arg("list"), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
pycowsay | ||
----- stderr ----- | ||
"###); | ||
|
||
rye_cmd_snapshot!( | ||
space.rye_cmd() | ||
.arg("tools") | ||
.arg("list") | ||
.arg("--version-show"), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
pycowsay 0.0.0.2 ([email protected]) | ||
----- stderr ----- | ||
"###); | ||
|
||
rye_cmd_snapshot!( | ||
space.rye_cmd() | ||
.arg("toolchain") | ||
.arg("remove") | ||
.arg("[email protected]"), @r###" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
----- stderr ----- | ||
error: toolchain [email protected] is still in use by tool pycowsay | ||
"###); | ||
|
||
rye_cmd_snapshot!( | ||
space.rye_cmd() | ||
.arg("tools") | ||
.arg("uninstall") | ||
.arg("pycowsay"), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
Uninstalled pycowsay | ||
----- stderr ----- | ||
"###); | ||
|
||
assert!(!space.rye_home().join("tools").join("pycowsay").is_dir()); | ||
} |