Git Product home page Git Product logo

Comments (5)

danjl1100 avatar danjl1100 commented on June 8, 2024 1

Thanks for the followup mention.

I plan on taking a look at implementing this, but likely wouldn't be until next weekend.

from cargo-mutants.

sourcefrog avatar sourcefrog commented on June 8, 2024

@danjl1100 no obligation, but if you want to take this one let me know.

from cargo-mutants.

danjl1100 avatar danjl1100 commented on June 8, 2024

My initial thoughts, any guiding feedback is welcome:

  • Thinking to use the same testdata/nested_mod test case, and add all the examples listed in the rust reference you linked. Possibly add more levels of nesting too, so it's fairly exhaustive.
  • Introduce a new struct (ModNamespace?) to contain the name and optional path for each module in the mod_namespace_stack: Vec<ModNamespace>

from cargo-mutants.

danjl1100 avatar danjl1100 commented on June 8, 2024

On further look, only the path to the module (not the module name identifiers) are used in find_mod_source. I am thinking an extra struct is not needed: the separation from namespace_stack (all rust identifiers) means that mod_namespace_stack can contain just the filesystem names for the modules (without carrying around name as well).

Though it may be helpful to add a struct FilesystemName(String) newtype wrapper to ensure we're acknowledging it's a path and not an identifier? (otherwise, may be unclear on a quick skim that the different Vec<String> fields are tracking subtly different values...)

UPDATE: mod_name is output by the warn!, do we want to keep the module name around for that purpose alone?

warn!(?parent_path, %mod_name, ?tried_paths, "referent of mod not found");

from cargo-mutants.

sourcefrog avatar sourcefrog commented on June 8, 2024

Using the same test case but with some addition modules containing #[path] attributes sounds good.

Even though it's not really a security boundary we should check that paths don't contain .. or /.

Though it may be helpful to add a struct FilesystemName(String) newtype wrapper to ensure we're acknowledging it's a path and not an identifier?

Yes, the Vec<Vec<String>> feels a bit loose. Though, on the other hand, maybe it should just be a Utf8PathBuf which is basically like a FilesystemName(String): a stack holding the relative directory we'll search, and then the visitor can accumulate the paths of actual modules we need to later find. Then we need to translate a/b/c to either a/b/c.rs or a/b/c/mod.rs unless we had a specific path for c, but there's already some code like that.

Regarding the "not found" message:

  1. Maybe that should be upgraded to an error rather than warning, and cause a non-zero exit.
  2. Maybe the more useful thing there would be to remember and report not just the mod name but the source file/line/col of the mod statement.

Also, I think this bug is some additional evidence for the refactor considered in #329 of separating walking mods from generating mutants, but that might be large so I'd rather do it myself. It shouldn't block or conflict with this.

from cargo-mutants.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.