-
-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
186 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,33 @@ toolchain = "[email protected]" | |
.unwrap(); | ||
} | ||
|
||
// write the credentials file | ||
let credentials_file = home.join("credentials"); | ||
if !credentials_file.is_file() { | ||
fs::write( | ||
credentials_file, | ||
r#" | ||
[pypi] | ||
[bad-repo] | ||
repository-url = "bad url" | ||
username = "bad name" | ||
token = "bad token" | ||
[good-repo-bad-auth] | ||
repository-url = "https://pypi.test.org/legacy/" | ||
token = "bad token" | ||
[good-repo-kerying] | ||
repository-url = "https://pypi.test.org/legacy/" | ||
username = "test-keyring" | ||
"#, | ||
) | ||
.unwrap(); | ||
} | ||
|
||
// fetch the most important interpreters | ||
for version in ["[email protected]", "[email protected]", "[email protected]"] { | ||
if home.join("py").join(version).is_dir() { | ||
|
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,159 @@ | ||
use crate::common::{get_bin, rye_cmd_snapshot, Space}; | ||
|
||
mod common; | ||
|
||
// Test publish command | ||
#[test] | ||
fn test_publish() { | ||
let space = Space::new(); | ||
space.init("my-project"); | ||
|
||
// Build 'my-project' for distribution | ||
space.rye_cmd().arg("build").status().unwrap(); | ||
|
||
rye_cmd_snapshot!(space.rye_cmd().arg("publish"), @r###" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
No access token found, generate one at: https://pypi.org/manage/account/token/ | ||
----- stderr ----- | ||
Access token: error: IO error: not a terminal | ||
Caused by: | ||
not a terminal | ||
"###); | ||
|
||
rye_cmd_snapshot!(space.rye_cmd().arg("publish").arg("--repository").arg("no-repo"), @r###" | ||
success: false | ||
exit_code: 1 | ||
----- stdout ----- | ||
----- stderr ----- | ||
error: no configuration was found for 'no-repo' | ||
"###); | ||
|
||
rye_cmd_snapshot!(space.rye_cmd().arg("publish").arg("--repository").arg("bad-repo"), @r###" | ||
"###); | ||
} | ||
|
||
// The default is the same as --lib | ||
#[test] | ||
fn test_init_default() { | ||
let space = Space::new(); | ||
space | ||
.cmd(get_bin()) | ||
.arg("init") | ||
.arg("--name") | ||
.arg("my-project") | ||
.arg("-q") | ||
.current_dir(space.project_path()) | ||
.status() | ||
.expect("initialization successful"); | ||
|
||
rye_cmd_snapshot!(space.rye_cmd().arg("sync"), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
Initializing new virtualenv in [TEMP_PATH]/project/.venv | ||
Python version: [email protected] | ||
Generating production lockfile: [TEMP_PATH]/project/requirements.lock | ||
Generating dev lockfile: [TEMP_PATH]/project/requirements-dev.lock | ||
Installing dependencies | ||
Done! | ||
----- stderr ----- | ||
Built 1 editable in [EXECUTION_TIME] | ||
Resolved 1 package in [EXECUTION_TIME] | ||
Built 1 editable in [EXECUTION_TIME] | ||
Resolved 1 package in [EXECUTION_TIME] | ||
Built 1 editable in [EXECUTION_TIME] | ||
Installed 1 package in [EXECUTION_TIME] | ||
+ my-project==0.1.0 (from file:[TEMP_PATH]/project) | ||
"###); | ||
|
||
rye_cmd_snapshot!(space.rye_cmd().arg("run").arg("python").arg("-c").arg("import my_project; print(my_project.hello())"), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
Hello from my-project! | ||
----- stderr ----- | ||
"###); | ||
|
||
assert!( | ||
space.read_toml("pyproject.toml")["project"] | ||
.get("scripts") | ||
.is_none(), | ||
"[project.scripts] should not be present" | ||
) | ||
} | ||
|
||
// Test that init --script works | ||
#[test] | ||
fn test_init_script() { | ||
let space = Space::new(); | ||
space | ||
.cmd(get_bin()) | ||
.arg("init") | ||
.arg("--name") | ||
.arg("my-project") | ||
.arg("-q") | ||
.arg("--script") | ||
.current_dir(space.project_path()) | ||
.status() | ||
.expect("initialization successful"); | ||
|
||
rye_cmd_snapshot!(space.rye_cmd().arg("sync"), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
Initializing new virtualenv in [TEMP_PATH]/project/.venv | ||
Python version: [email protected] | ||
Generating production lockfile: [TEMP_PATH]/project/requirements.lock | ||
Generating dev lockfile: [TEMP_PATH]/project/requirements-dev.lock | ||
Installing dependencies | ||
Done! | ||
----- stderr ----- | ||
Built 1 editable in [EXECUTION_TIME] | ||
Resolved 1 package in [EXECUTION_TIME] | ||
Built 1 editable in [EXECUTION_TIME] | ||
Resolved 1 package in [EXECUTION_TIME] | ||
Built 1 editable in [EXECUTION_TIME] | ||
Installed 1 package in [EXECUTION_TIME] | ||
+ my-project==0.1.0 (from file:[TEMP_PATH]/project) | ||
"###); | ||
|
||
rye_cmd_snapshot!(space.rye_cmd().arg("run").arg("hello"), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
Hello from my-project! | ||
----- stderr ----- | ||
"###); | ||
|
||
rye_cmd_snapshot!(space.rye_cmd().arg("run").arg("python").arg("-mmy_project"), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
Hello from my-project! | ||
----- stderr ----- | ||
"###); | ||
} | ||
|
||
// Test that init --script and --lib are incompatible. | ||
#[test] | ||
fn test_init_lib_and_script_incompatible() { | ||
let space = Space::new(); | ||
rye_cmd_snapshot!(space.cmd(get_bin()).arg("init").arg("--name").arg("my-project").arg("--script").arg("--lib").current_dir(space.project_path()), @r###" | ||
success: false | ||
exit_code: 2 | ||
----- stdout ----- | ||
----- stderr ----- | ||
error: an argument cannot be used with one or more of the other specified arguments | ||
"###); | ||
} |