-
Notifications
You must be signed in to change notification settings - Fork 23
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
Conversation
There was a problem hiding this 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, |
There was a problem hiding this comment.
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)
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 })
}
}
There was a problem hiding this comment.
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 })
}
}
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
that seems to work, thanks!
…On Tue, Dec 3, 2024 at 8:53 PM Nico Lehmann ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In crates/flux-config/src/lib.rs
<https://urldefense.com/v3/__https://github.com/flux-rs/flux/pull/917*discussion_r1868716360__;Iw!!Mih3wA!C6FahVPO48h7bQw_wsGzd2MZtRAYOJpdtx-8JGd1hNVH5PjrN8Zd2nP8YG_ziaFAIZa_73ae5i8Jvp0aTHeGcJbz$>
:
> @@ -81,6 +85,7 @@ struct Config {
catch_bugs: bool,
pointer_width: PointerWidth,
check_def: String,
+ check_files: String,
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
—
Reply to this email directly, view it on GitHub
<https://urldefense.com/v3/__https://github.com/flux-rs/flux/pull/917*discussion_r1868716360__;Iw!!Mih3wA!C6FahVPO48h7bQw_wsGzd2MZtRAYOJpdtx-8JGd1hNVH5PjrN8Zd2nP8YG_ziaFAIZa_73ae5i8Jvp0aTHeGcJbz$>,
or unsubscribe
<https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AAMS4OD2BBOIXA5VO6FZKMT2D2DCXAVCNFSM6AAAAABS6XJBU2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDINZXGI4DINBXGA__;!!Mih3wA!C6FahVPO48h7bQw_wsGzd2MZtRAYOJpdtx-8JGd1hNVH5PjrN8Zd2nP8YG_ziaFAIZa_73ae5i8Jvp0aTEFfcqTK$>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
- Ranjit.
|
Spoke to soon - will try to decipher tomorrow
- Ranjit.
…On Tue, Dec 3, 2024 at 9:13 PM Ranjit Jhala ***@***.***> wrote:
that seems to work, thanks!
On Tue, Dec 3, 2024 at 8:53 PM Nico Lehmann ***@***.***>
wrote:
> ***@***.**** commented on this pull request.
> ------------------------------
>
> In crates/flux-config/src/lib.rs
> <https://urldefense.com/v3/__https://github.com/flux-rs/flux/pull/917*discussion_r1868716360__;Iw!!Mih3wA!C6FahVPO48h7bQw_wsGzd2MZtRAYOJpdtx-8JGd1hNVH5PjrN8Zd2nP8YG_ziaFAIZa_73ae5i8Jvp0aTHeGcJbz$>
> :
>
> > @@ -81,6 +85,7 @@ struct Config {
> catch_bugs: bool,
> pointer_width: PointerWidth,
> check_def: String,
> + check_files: String,
>
> 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
>
> —
> Reply to this email directly, view it on GitHub
> <https://urldefense.com/v3/__https://github.com/flux-rs/flux/pull/917*discussion_r1868716360__;Iw!!Mih3wA!C6FahVPO48h7bQw_wsGzd2MZtRAYOJpdtx-8JGd1hNVH5PjrN8Zd2nP8YG_ziaFAIZa_73ae5i8Jvp0aTHeGcJbz$>,
> or unsubscribe
> <https://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AAMS4OD2BBOIXA5VO6FZKMT2D2DCXAVCNFSM6AAAAABS6XJBU2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDINZXGI4DINBXGA__;!!Mih3wA!C6FahVPO48h7bQw_wsGzd2MZtRAYOJpdtx-8JGd1hNVH5PjrN8Zd2nP8YG_ziaFAIZa_73ae5i8Jvp0aTEFfcqTK$>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
--
- Ranjit.
|
Adds a flag to make
flux
only checkDefId
in specified files... (to enable more interactive checking)