huak icon indicating copy to clipboard operation
huak copied to clipboard

Error on cargo test

Open AtomsForPeace opened this issue 1 year ago • 22 comments

Expected Behavior

Tests run.

Actual Behavior

Get an error when running cargo test.

Steps to Reproduce

Clone repo and run cargo test.

Version

version = "0.0.18"

System Information

Linux Mint 19.3 Tricia, Python 3.9.7

Here's the output:

huak git:(master) ✗ cargo test Finished test [unoptimized + debuginfo] target(s) in 0.05s Running unittests src/huak/lib.rs (target/debug/deps/huak-2f5a37d206be1267)

running 35 tests test fs::tests::test_copy_dir ... ok test fs::tests::test_find_root_file_bottom_up ... ok test dependency::tests::dependency_from_str ... ok test metadata::tests::toml_dependencies ... ok test metadata::tests::toml_add_optional_dependency ... ok test metadata::tests::toml_add_dependency ... ok test metadata::tests::toml_from_path ... ok test git::tests::test_init ... ok test metadata::tests::toml_optional_dependencies ... ok test metadata::tests::toml_to_string_pretty ... ok test metadata::tests::toml_remove_dependency ... ok test metadata::tests::toml_remove_optional_dependency ... ok test ops::clean::tests::test_clean_project ... ok error: Collecting ruff Using cached https://files.pythonhosted.org/packages/aa/ed/7adc91572c08f346976335f6b1b22774ea555d11043a9ff013f962affab5/ruff-0.0.17.tar.gz Installing build dependencies: started Installing build dependencies: finished with status 'error' Complete output from command /tmp/.tmplnDPZs/mock-project/.venv/bin/python -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-oadlcr7g --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- maturin>=0.13,<0.14: Collecting maturin<0.14,>=0.13 Could not find a version that satisfies the requirement maturin<0.14,>=0.13 (from versions: 0.7.1, 0.7.2, 0.7.6, 0.7.7, 0.7.8, 0.7.9, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.9.0, 0.9.1, 0.9.4, 0.10.0, 0.10.2, 0.10.3, 0.10.4, 0.10.5, 0.10.6, 0.11.0, 0.11.1, 0.11.2, 0.11.3, 0.11.4, 0.11.5, 0.12.0, 0.12.1, 0.12.2, 0.12.3, 0.12.4, 0.12.5, 0.12.6, 0.12.7, 0.12.8, 0.12.9, 0.12.10, 0.12.11, 0.12.12, 0.12.13, 0.12.14, 0.12.15, 0.12.16, 0.12.17, 0.12.18b2, 0.12.18, 0.12.19, 0.12.20) No matching distribution found for maturin<0.14,>=0.13 You are using pip version 18.1, however version 21.3.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.


error: Command "/tmp/.tmplnDPZs/mock-project/.venv/bin/python -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-oadlcr7g --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- maturin>=0.13,<0.14" failed with error code 1 in None You are using pip version 18.1, however version 21.3.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

error: test failed, to rerun pass --lib

Caused by: process didn't exit successfully: /home/adam/Projects/huak/target/debug/deps/huak-2f5a37d206be1267 (exit status: 1)

AtomsForPeace avatar Apr 25 '23 10:04 AtomsForPeace

If you feel up to it, would you be willing to try with a newer Python version?

Otherwise I'll look at this more today.

Are you able to build the project?

cnpryer avatar Apr 25 '23 13:04 cnpryer

I tried updating my python version but see that it uses 3.6.9 in fact. I see that when I check the version of this path: /tmp/.tmp6gmGdi/mock-project/.venv/bin/python

How is the python version chosen? I have an alias for python -> python3.11

Building succeeds

AtomsForPeace avatar Apr 25 '23 14:04 AtomsForPeace

If it builds from source I'd be curious if you're having some of these issues on the latest master. v0.0.19 refines a lot of stuff. I also forget if v0.0.18 shipped the huak python subcommand. If it does, you could run huak python list. At the moment huak just uses the first Python interpreter listed on your PATH to create a venv.

/tmp/.tmp6gmGdi/mock-project/.venv/bin/python is part of the tests. For the tests we create venvs in temporary directories to isolate the tests completely. That's from a venv created in a temporary directory for that test.

How is the python version chosen? I have an alias for python -> python3.11

huak used to just default to the alias. I'm not opposed to thinking about this again, but I'm trying to move towards a future where if you want to use venvs there's a very straight-forward way to use it (v0.0.19 would be huak python use 3.11). Otherwise I'd like to look into PyBI.

If you're able to build you could tinker with master by running cargo install --path . in the repo's root.

cnpryer avatar Apr 25 '23 14:04 cnpryer

I have been on the latest master throughout I believe.

So it's expected that that mock python venv uses 3.6.9?

I ran cargo install --path . I then ran the tests again but got the same error

AtomsForPeace avatar Apr 25 '23 15:04 AtomsForPeace

I apologize for the confusion. I've mingled our conversations between the two issues we're looking at.

The cargo install won't impact the tests. I suggested trying it just to see if you're running into some of the non-testing issues you're seeing. If something stood out it might have helped us understand this one since huak uses the default Python resolution for the tests.

It looks like the python subcommand is available in v0.0.18 so you should be able to run it either way. Try huak python list.

So it's expected that that mock python venv uses 3.6.9?

Those tests should be using the first path listed in the huak python list result. So I think the tests are failing because it's using 3.6.9 (unrelated to your other issues).

https://github.com/PyO3/maturin/blob/3807c2bcdd9f49fdc6e8b5dc7de6ca1f879b1dfb/pyproject.toml#L8

cnpryer avatar Apr 25 '23 15:04 cnpryer

I apologize for the confusion. I've mingled our conversations between the two issues we're looking at.

No worries, I feel the same.

If I run huak python use 3.11, that doesn't seem to affect which python it uses. Is there a way I can change the order of list or remove python versions from it?

AtomsForPeace avatar Apr 25 '23 18:04 AtomsForPeace

I'll look into setting the tests up so that it always uses the latest Python version found from PATH. In the future it'd be nice to just test 3.7 thru 3.X.

cnpryer avatar Apr 25 '23 19:04 cnpryer

Hey If you want to try out #627 that might fix this for you.

cnpryer avatar Apr 25 '23 20:04 cnpryer

I tried out at that commit. I'm not sure why but my list has changed (probably something I did): huak python list
1: /usr/local/bin/python3.7 2: /usr/local/bin/python3.6 3: /usr/local/bin/python3.9 4: /usr/bin/python3.11 5: /usr/bin/python3.10 6: /usr/bin/python2.7 7: /usr/bin/python3.7 8: /usr/bin/python3.6 9: /usr/bin/python3.9 10: /usr/bin/python3.8

Now when I run cargo test I get a different error: error: Collecting click==8.1.3 Using cached https://files.pythonhosted.org/packages/c2/f1/df59e28c642d583f7dacffb1e0965d0e00b218e0186d7858ac5233dce840/click-8.1.3-py3-none-any.whl Collecting pytest>=6 Using cached https://files.pythonhosted.org/packages/1b/d1/72df649a705af1e3a09ffe14b0c7d3be1fd730da6b98beb4a2ed26b8a023/pytest-7.3.1-py3-none-any.whl Collecting black==22.8.0 Using cached https://files.pythonhosted.org/packages/c6/63/a852b07abc942dc069b5457af40feca82667cf5ed9faec7d4688a4d9c7da/black-22.8.0-py3-none-any.whl Collecting isort==5.12.0

error: Could not find a version that satisfies the requirement isort==5.12.0 (from versions: 1.0.0, 1.0.1, 1.2.0, 1.2.2, 1.2.3, 1.2.5, 1.3.0, 1.3.1, 1.3.2, 2.0.0, 2.0.1, 2.1.0, 2.2.0, 2.2.1, 2.3.0, 2.4.0, 2.4.1, 2.5.0, 2.6.0, 2.6.1, 2.6.2, 2.6.3, 3.0.0, 3.1.0, 3.1.1, 3.1.2, 3.2.0, 3.3.0, 3.3.1, 3.4.0, 3.4.1, 3.4.2, 3.5.0, 3.6.0, 3.6.1, 3.6.2, 3.7.0, 3.7.1, 3.7.2, 3.8.0, 3.8.1, 3.8.2, 3.8.3, 3.9.0, 3.9.1, 3.9.2, 3.9.3, 3.9.4, 3.9.5, 3.9.6, 4.0.0, 4.1.0, 4.1.1, 4.1.2, 4.2.0, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 4.2.5, 4.2.8, 4.2.9, 4.2.11, 4.2.12, 4.2.13, 4.2.14, 4.2.15, 4.3.0, 4.3.1, 4.3.2, 4.3.3, 4.3.4, 4.3.5, 4.3.6, 4.3.7, 4.3.8, 4.3.9, 4.3.10, 4.3.11, 4.3.12, 4.3.13, 4.3.14, 4.3.15, 4.3.16, 4.3.17, 4.3.18, 4.3.19, 4.3.20, 4.3.21, 5.0.0, 5.0.1, 5.0.2, 5.0.3, 5.0.4, 5.0.5, 5.0.6, 5.0.7, 5.0.8, 5.0.9, 5.1.0, 5.1.1, 5.1.2, 5.1.3, 5.1.4, 5.2.0, 5.2.1, 5.2.2, 5.3.0, 5.3.1, 5.3.2, 5.4.0, 5.4.1, 5.4.2, 5.5.0, 5.5.1, 5.5.2, 5.5.3, 5.5.4, 5.5.5, 5.6.0, 5.6.1, 5.6.2, 5.6.3, 5.6.4, 5.7.0, 5.8.0, 5.9.0, 5.9.1, 5.9.2, 5.9.3, 5.10.0, 5.10.1, 5.11.0, 5.11.1, 5.11.2, 5.11.3, 5.11.4, 5.11.5, 6.0.0a1, 6.0.0b1, 6.0.0b2) No matching distribution found for isort==5.12.0 You are using pip version 19.0.3, however version 23.1.2 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

error: test failed, to rerun pass --lib

Caused by: process didn't exit successfully: /home/adam/Projects/huak/target/debug/deps/huak-1e47d06865c70764 (exit status: 1)

AtomsForPeace avatar Apr 26 '23 12:04 AtomsForPeace

If you want to give it another try I pushed what should have fixed that in #630

cnpryer avatar Apr 26 '23 14:04 cnpryer

To clarify, I merged the fix into the PR you're testing (#627)

cnpryer avatar Apr 26 '23 15:04 cnpryer

Tried it out. I'm on master at bd92850 but still getting the above errors

AtomsForPeace avatar Apr 26 '23 15:04 AtomsForPeace

Use #627. master doesn't have the changes to the tests to use the latest Python. I don't want to merge it until I know it resolves this issue.

cnpryer avatar Apr 26 '23 15:04 cnpryer

But I think I already checked on that commit. It give me the same error as shown above.

AtomsForPeace avatar Apr 26 '23 15:04 AtomsForPeace

This commit? If it's easier I could merge it, closing this issue, and then if you're still having issues with the tests we can re-open.

FWIW I've really enjoyed using gh cli. With it you could

❯ gh pr checkout 627

And if you already have the branch you just need to pull the latest changes.

❯ git pull

cnpryer avatar Apr 26 '23 15:04 cnpryer

FWIW I've really enjoyed using gh cli. With it you could

❯ gh pr checkout 627

Looks cool. Will try that out, thanks!

I'm now on the commit you linked but I'm still getting the above errors that start with error: Collecting click

AtomsForPeace avatar Apr 26 '23 15:04 AtomsForPeace

Hmm. I guess if you'd like to check what's going you could debug to see which Python version your tests are using. I can't reproduce this at this point.

One other thing that could be happening is that you could have a venv for some reason in dev-resource/mock-project. The tests would copy that over.

I'll merge the PR without closing this issue.

cnpryer avatar Apr 26 '23 15:04 cnpryer

We could also just modify the mock-project requirements listed, but I'd still like to understand what's happening to your tests.

cnpryer avatar Apr 26 '23 15:04 cnpryer

I tried to find a way to do that but haven't found how to. How do you suggest I see what python I'm using there? I can't even see which test fails.

AtomsForPeace avatar Apr 26 '23 16:04 AtomsForPeace

I can't even see which test fails.

Huh I'm not sure what you mean by this. What's your dev environment and how are you running the tests?

To see what interpreter it's using I was just debugging the venv bootstrapping method used for ops tests (currently called test_venv). Atm I'm using vscode. So the debugger is a vscode extension.

You could also just add a dbg!() to print the python path it's using.

cnpryer avatar Apr 26 '23 16:04 cnpryer

Actually i think i know whats happening regarding not seeing which tests fail.

#591

Basically if a subprocess fails the main process just exits early. I plan to change this at some point, but that should explain why you're not seeing the failing tests in the cargo stdout.

cnpryer avatar Apr 26 '23 16:04 cnpryer

Also if you'd like I could help with this in discord as well.

cnpryer avatar Apr 26 '23 16:04 cnpryer