Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta: Allow cargo's tests to be run in-process for debugging #9757

Closed
gilescope opened this issue Aug 3, 2021 · 1 comment · Fixed by #9904
Closed

meta: Allow cargo's tests to be run in-process for debugging #9757

gilescope opened this issue Aug 3, 2021 · 1 comment · Fixed by #9904
Labels
A-testing-cargo-itself Area: cargo's tests C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@gilescope
Copy link
Contributor

Almost all the cargo tests test cargo as an external process which is great from a purity standpoint.

Unfortunatly llvm doesn't support debugging child processes ( vadimcn/codelldb#317 ), so it's not possible to use an llvm debugger to debug into cargo from a failing test.

It would be really helpful if in cargo-test-support rather than starting a new process there was a flag (maybe an env var set?) to tell it to call the main function directly from the test instead of routing it through a new process. I'm sure all tests won't magically run clean that way, but if the majority do that would be very helpful. I'm sure it's not quite that easy, but being able to debug into cargo from most failing tests would likely reduce the bar to contributing to cargo.

@gilescope gilescope added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Aug 3, 2021
@ehuss
Copy link
Contributor

ehuss commented Aug 4, 2021

I think it is unlikely we would want to rework the test system to work like that. What I normally do is just run cargo directly in the test environment. I don't use lldb much, but that is what I would do. Essentially:

  1. Run cargo test --test testsuite -- my_test_name. This should run just one test, and presumably would fail at some point.
  2. In another terminal:
    1. cd target/debug/tmp/cit/t0
    2. export CARGO_HOME=$(pwd)/home/.cargo.
    3. cd foo
  3. Run whatever cargo command you want. If you are debugging, you can run lldb /path/to/cargo/target/debug/cargo. You'll need to re-enter whatever environment variables and CLI options the test was executing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing-cargo-itself Area: cargo's tests C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants