forked from astral-sh/rye
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug that caused impartial lock options recalling (astral-sh#830)
- Loading branch information
Showing
3 changed files
with
175 additions
and
19 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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
use std::fs; | ||
|
||
use insta::{assert_snapshot, Settings}; | ||
|
||
use crate::common::{rye_cmd_snapshot, Space}; | ||
|
||
mod common; | ||
|
@@ -119,3 +121,143 @@ fn test_add_autosync() { | |
+ werkzeug==3.0.1 | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn test_autosync_remember() { | ||
// remove the dependency source markers since they are instable between platforms | ||
let mut settings = Settings::clone_current(); | ||
settings.add_filter(r"(?m)^\s+# via .*\r?\n", ""); | ||
settings.add_filter(r"(?m)^(\s+)\d+\.\d+s( \d+ms)?", "$1[TIMING]"); | ||
let _guard = settings.bind_to_scope(); | ||
|
||
let space = Space::new(); | ||
space.init("my-project"); | ||
rye_cmd_snapshot!(space.rye_cmd().arg("sync").arg("--with-sources").arg("--all-features"), @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] | ||
Installed 1 package in [EXECUTION_TIME] | ||
+ my-project==0.1.0 (from file:[TEMP_PATH]/project) | ||
"###); | ||
|
||
rye_cmd_snapshot!(space.rye_cmd() | ||
.arg("add").arg("--optional=web").arg("flask==3.0.0").arg("colorama"), | ||
@r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
Added flask>=3.0.0 as optional (web) dependency | ||
Added colorama>=0.4.6 as optional (web) dependency | ||
Reusing already existing virtualenv | ||
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 8 packages in [EXECUTION_TIME] | ||
Downloaded 8 packages in [EXECUTION_TIME] | ||
Uninstalled 1 package in [EXECUTION_TIME] | ||
Installed 9 packages in [EXECUTION_TIME] | ||
+ blinker==1.7.0 | ||
+ click==8.1.7 | ||
+ colorama==0.4.6 | ||
+ flask==3.0.0 | ||
+ itsdangerous==2.1.2 | ||
+ jinja2==3.1.2 | ||
+ markupsafe==2.1.3 | ||
- my-project==0.1.0 (from file:[TEMP_PATH]/project) | ||
+ my-project==0.1.0 (from file:[TEMP_PATH]/project) | ||
+ werkzeug==3.0.1 | ||
"###); | ||
assert_snapshot!(std::fs::read_to_string(space.project_path().join("requirements.lock")).unwrap(), @r###" | ||
# generated by rye | ||
# use `rye lock` or `rye sync` to update this lockfile | ||
# | ||
# last locked with the following flags: | ||
# pre: false | ||
# features: [] | ||
# all-features: true | ||
# with-sources: true | ||
--index-url https://pypi.org/simple/ | ||
-e file:. | ||
blinker==1.7.0 | ||
click==8.1.7 | ||
colorama==0.4.6 | ||
flask==3.0.0 | ||
itsdangerous==2.1.2 | ||
jinja2==3.1.2 | ||
markupsafe==2.1.3 | ||
werkzeug==3.0.1 | ||
"###); | ||
|
||
rye_cmd_snapshot!(space.rye_cmd().arg("add").arg("urllib3"), | ||
@r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
Added urllib3>=2.1.0 as regular dependency | ||
Reusing already existing virtualenv | ||
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] | ||
Downloaded 1 package in [EXECUTION_TIME] | ||
Uninstalled 1 package in [EXECUTION_TIME] | ||
Installed 2 packages in [EXECUTION_TIME] | ||
- my-project==0.1.0 (from file:[TEMP_PATH]/project) | ||
+ my-project==0.1.0 (from file:[TEMP_PATH]/project) | ||
+ urllib3==2.1.0 | ||
"###); | ||
|
||
// would be nice to assert on the non quiet output here but unfortunately | ||
// on CI we seem to have some flakage on this command with regards to | ||
// rebuilding the editable. | ||
rye_cmd_snapshot!(space.rye_cmd().arg("sync").arg("-q"), @r###" | ||
success: true | ||
exit_code: 0 | ||
----- stdout ----- | ||
----- stderr ----- | ||
"###); | ||
|
||
assert_snapshot!(std::fs::read_to_string(space.project_path().join("requirements.lock")).unwrap(), @r###" | ||
# generated by rye | ||
# use `rye lock` or `rye sync` to update this lockfile | ||
# | ||
# last locked with the following flags: | ||
# pre: false | ||
# features: [] | ||
# all-features: true | ||
# with-sources: true | ||
--index-url https://pypi.org/simple/ | ||
-e file:. | ||
blinker==1.7.0 | ||
click==8.1.7 | ||
colorama==0.4.6 | ||
flask==3.0.0 | ||
itsdangerous==2.1.2 | ||
jinja2==3.1.2 | ||
markupsafe==2.1.3 | ||
urllib3==2.1.0 | ||
werkzeug==3.0.1 | ||
"###); | ||
} |