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

Check specified files (only) #917

Merged
merged 4 commits into from
Dec 4, 2024
Merged

Check specified files (only) #917

merged 4 commits into from
Dec 4, 2024

Conversation

ranjitjhala
Copy link
Contributor

Adds a flag to make flux only check DefId in specified files... (to enable more interactive checking)

Copy link
Member

@nilehmann nilehmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just one suggestion to make the configuration more structured.

@@ -81,6 +85,7 @@ struct Config {
catch_bugs: bool,
pointer_width: PointerWidth,
check_def: String,
check_files: String,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can parse this as a list of paths (I haven't tested it)

Suggested change
check_files: String,
check_files: Paths,

and then

#[derive(Default)]
struct Paths {
    paths: Vec<PathBuf>,
}

impl<'de> Deserialize<'de> for Paths {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let paths = <&str>::deserialize(deserializer)?
            .split(',')
            .into_iter()
            .map(PathBuf::from)
            .collect();
        Ok(Paths { paths })
    }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or more generally we could have a way to parse arbitrary lists

struct List<T> {
    values: Vec<T>,
}

impl<'de, T> Deserialize<'de> for List<T>
where
    T: Deserialize<'de>,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let values = <&str>::deserialize(deserializer)?
            .split(',')
            .into_iter()
            .map(|s| T::deserialize(StrDeserializer::new(s)))
            .collect::<Result<_, _>>()?;
        Ok(List { values })
    }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting this weird error (when using the PathBuf code)?

rjhala@pozole ~/r/flux-demo (main) [101]> RUST_BACKTRACE=1 FLUX_CHECK_FILES=src/basics.rs cargo flux
error: process didn't exit successfully: `/Users/rjhala/.flux/flux-driver -vV` (exit status: 101)
--- stderr
thread 'main' panicked at crates/flux-config/src/lib.rs:181:13:
called `Result::unwrap()` on an `Err` value: invalid type: string "src/basics.rs", expected a borrowed string
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can try:

impl<'de> Deserialize<'de> for Paths {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let paths = String::deserialize(deserializer)?
            .split(',')
            .into_iter()
            .map(PathBuf::from)
            .collect();
        Ok(Paths { paths })
    }
}

if that doesn't work nvm

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-( am making the above a separate issue so I can merge this stuff in now...

crates/flux-config/src/lib.rs Show resolved Hide resolved
@ranjitjhala ranjitjhala mentioned this pull request Dec 4, 2024
@ranjitjhala ranjitjhala merged commit 84dd708 into main Dec 4, 2024
7 checks passed
@ranjitjhala ranjitjhala deleted the check-files branch December 4, 2024 05:01
@ranjitjhala ranjitjhala mentioned this pull request Dec 4, 2024
@ranjitjhala
Copy link
Contributor Author

ranjitjhala commented Dec 4, 2024 via email

@ranjitjhala
Copy link
Contributor Author

ranjitjhala commented Dec 4, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants