@@ -123,10 +123,39 @@ If you need to test with registry dependencies, see
123
123
If you need to test git dependencies, see [ ` support::git ` ] to create a git
124
124
dependency.
125
125
126
+ ## Debugging tests
127
+
128
+ In some cases, you may need to dig into a test that is not working as you
129
+ expect, or you just generally want to experiment within the sandbox
130
+ environment. The general process is:
131
+
132
+ 1 . Build the sandbox for the test you want to investigate. For example:
133
+
134
+ ` cargo test --test testsuite -- features2::inactivate_targets ` .
135
+ 2 . In another terminal, head into the sandbox directory to inspect the files and run ` cargo ` directly.
136
+ 1 . The sandbox directories start with ` t0 ` for the first test.
137
+
138
+ ` cd target/tmp/cit/t0 `
139
+ 2 . Set up the environment so that the sandbox configuration takes effect:
140
+
141
+ ` export CARGO_HOME=$(pwd)/home/.cargo `
142
+ 3 . Most tests create a ` foo ` project, so head into that:
143
+
144
+ ` cd foo `
145
+ 3 . Run whatever cargo command you want. See [ Running Cargo] for more details
146
+ on running the correct ` cargo ` process. Some examples:
147
+
148
+ * ` /path/to/my/cargo/target/debug/cargo check `
149
+ * Using a debugger like ` lldb ` or ` gdb ` :
150
+ 1 . ` lldb /path/to/my/cargo/target/debug/cargo `
151
+ 2 . Set a breakpoint, for example: ` b generate_targets `
152
+ 3 . Run with arguments: ` r check `
153
+
126
154
[ `testsuite` ] : https://github.com/rust-lang/cargo/tree/master/tests/testsuite/
127
155
[ `ProjectBuilder` ] : https://github.com/rust-lang/cargo/blob/e4b65bdc80f2a293447f2f6a808fa7c84bf9a357/crates/cargo-test-support/src/lib.rs#L225-L231
128
156
[ `Execs` ] : https://github.com/rust-lang/cargo/blob/e4b65bdc80f2a293447f2f6a808fa7c84bf9a357/crates/cargo-test-support/src/lib.rs#L558-L579
129
157
[ `support` ] : https://github.com/rust-lang/cargo/blob/master/crates/cargo-test-support/src/lib.rs
130
158
[ `support::compare` ] : https://github.com/rust-lang/cargo/blob/master/crates/cargo-test-support/src/compare.rs
131
159
[ `support::registry::Package` ] : https://github.com/rust-lang/cargo/blob/e4b65bdc80f2a293447f2f6a808fa7c84bf9a357/crates/cargo-test-support/src/registry.rs#L73-L149
132
160
[ `support::git` ] : https://github.com/rust-lang/cargo/blob/master/crates/cargo-test-support/src/git.rs
161
+ [ Running Cargo ] : ../process/working-on-cargo.md#running-cargo
0 commit comments