Comments (7)
Hi, thanks for the report and reproduction.
I think the problem here is that cargo-mutants makes a copy of the tree before mutating it, so any paths relative to the original location won't work, as in your reproduction tree.
https://github.com/sourcefrog/cargo-mutants#:~:text=dependencies%20by%20a%20relative%20path
Using an absolute path should work, but that's not always convenient, and I'd like for it to just work without the user needing to make any prior adjustments.
There seem to be a few options:
- Rewrite
Cargo.toml
after copying to use absolute paths for any relative paths pointing out of the tree. Perhaps this is best. As a step towards this we could at least look for them and error cleanly. - Give an option to mutate the tree in place (and put it back afterwards.) This would avoid any patch related issues, but there's some risk that the mutation is actually not cleaned up properly if the program stops abruptly -- and anyhow the user would have to work out to use this option, which is not ideal.
- An option to copy a larger, enclosing, directory, perhaps containing all the dependencies. But again the user needs to understand that they need it.
Probably rewriting paths in Cargo.toml
is the best way to make it just work automatically. This also needs to handle the patch
and .cargo/config.toml
for overriding dependencies (https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html).
from cargo-mutants.
- Find all
Cargo.toml
files in the tree to be copied: there might be some in subdirectories. (Possibly we should not copy nested crates and instead turn them into relative references?) - Parse
Cargo.toml
probably using https://docs.rs/toml/ - Write out the possibly-modified file into the scratch directory.
- Walk the toml looking for
path
attributes on dependencies. - Also look for
patch
orreplace
sections. - For every relative path, replace it with an absolute path, resolved from the directory where it occurs.
- Also look for and modify
.cargo/config.toml
.
from cargo-mutants.
#43 fixes the particular case of path
dependencies, although not yet all the other case. It does work on your reproduction repo. @dmoka , maybe you can try it on your bigger project?
from cargo-mutants.
Wow, many thanks for your detailed investigation and your quick fix, much appreciated, Martin @sourcefrog !
Absolutely, happy to give it a try. I see that the latest crate version is still the v0.2.7
which does not contain this latest fix, if I am not mistaken.
What is the easiest way to get the fixed version of the crate and trying out locally?
Thanks again, and have a great day!
from cargo-mutants.
Yep, it's not released yet. I'm pretty sure this works but let's check it:
- Clone this repo
- Switch to the 'relpath' branch
cargo install --path .
- Run
cargo mutants
on your tree
from cargo-mutants.
Just checked it, and the relative-path issue has been indeed resolved.
Great job, thanks for the support!
from cargo-mutants.
ok this is released in 0.2.8
from cargo-mutants.
Related Issues (20)
- Follow `path` attribute on inline `mod` blocks HOT 5
- CI job that tests against some interesting/popular open source trees
- Try using a build profile that is quick but has no debug symbols
- More detail in CONTRIBUTING.md or the book about how to add new patterns
- Automatically merge results from multiple sharded jobs
- Test that requires copying `.git` HOT 3
- Support more cargo test flags HOT 2
- cargo-mutants doesn't work on tarpaulin tree HOT 1
- Check up on Debian packaging HOT 1
- Tests fail in unpacked crates.io crate tarball, due to missing testdata HOT 7
- Test building with the oldest allowed dependencies HOT 1
- Maybe force off cargo ansi colors in builds and tests
- `--jobs` has extra rebuilds of dependencies, causing build timeouts HOT 3
- Build fails when target file makes use of the include_str macro for reading data HOT 3
- Book site does not auto update on releases
- Test suite leaks rustc on `cargo_mutants_testdata_hang_when_mutated`
- Reconsider use of --cap-lints
- Unable to Set User Password via REST API in OpenDJ HOT 1
- Please update the crate fs2-0.4.0 to fs2-0.4.3
- Tests are running, but cargo-mutants detects 0 mutants to test
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo-mutants.