Skip to content

Commit

Permalink
Fix Rust 1.80.0 warnings (#2281)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jul 27, 2024
1 parent df9774d commit 044b00a
Show file tree
Hide file tree
Showing 14 changed files with 185 additions and 182 deletions.
16 changes: 16 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ pretty_assertions = "1.0.0"
temptree = "0.2.0"
which = "6.0.0"

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }

[lints.clippy]
all = { level = "deny", priority = -1 }
enum_glob_use = "allow"
needless_pass_by_value = "allow"
pedantic = { level = "deny", priority = -1 }
similar_names = "allow"
struct_excessive_bools = "allow"
struct_field_names = "allow"
too_many_arguments = "allow"
too_many_lines = "allow"
unnecessary_wraps = "allow"
wildcard_imports = "allow"

[lib]
doctest = false

Expand Down
15 changes: 0 additions & 15 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
#![deny(clippy::all, clippy::pedantic)]
#![allow(
clippy::enum_glob_use,
clippy::let_underscore_untyped,
clippy::needless_pass_by_value,
clippy::similar_names,
clippy::struct_excessive_bools,
clippy::struct_field_names,
clippy::too_many_arguments,
clippy::too_many_lines,
clippy::unnecessary_wraps,
clippy::wildcard_imports,
overlapping_range_endpoints
)]

//! `just` is primarily used as a command-line binary, but does provide a
//! limited public library interface.
//!
Expand Down
3 changes: 1 addition & 2 deletions tests/error_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,11 @@ fn file_paths_are_relative() {
.stderr(format!(
"
error: Expected '*', ':', '$', identifier, or '+', but found end of file
——▶ foo{}bar.just:1:4
——▶ foo{MAIN_SEPARATOR}bar.just:1:4
1 │ baz
│ ^
",
MAIN_SEPARATOR
))
.run();
}
Expand Down
54 changes: 27 additions & 27 deletions tests/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,48 @@ use super::*;

test! {
name: test_os_arch_functions_in_interpolation,
justfile: r#"
justfile: r"
foo:
echo {{arch()}} {{os()}} {{os_family()}} {{num_cpus()}}
"#,
",
stdout: format!("{} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
stderr: format!("echo {} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
}

test! {
name: test_os_arch_functions_in_expression,
justfile: r#"
justfile: r"
a := arch()
o := os()
f := os_family()
n := num_cpus()
foo:
echo {{a}} {{o}} {{f}} {{n}}
"#,
",
stdout: format!("{} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
stderr: format!("echo {} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
}

#[cfg(not(windows))]
test! {
name: env_var_functions,
justfile: r#"
justfile: r"
p := env_var('USER')
b := env_var_or_default('ZADDY', 'HTAP')
x := env_var_or_default('XYZ', 'ABC')
foo:
/usr/bin/env echo '{{p}}' '{{b}}' '{{x}}'
"#,
",
stdout: format!("{} HTAP ABC\n", env::var("USER").unwrap()).as_str(),
stderr: format!("/usr/bin/env echo '{}' 'HTAP' 'ABC'\n", env::var("USER").unwrap()).as_str(),
}

#[cfg(not(windows))]
test! {
name: path_functions,
justfile: r#"
justfile: r"
we := without_extension('/foo/bar/baz.hello')
fs := file_stem('/foo/bar/baz.hello')
fn := file_name('/foo/bar/baz.hello')
Expand All @@ -53,15 +53,15 @@ jn := join('a', 'b')
foo:
/usr/bin/env echo '{{we}}' '{{fs}}' '{{fn}}' '{{dir}}' '{{ext}}' '{{jn}}'
"#,
",
stdout: "/foo/bar/baz baz baz.hello /foo/bar hello a/b\n",
stderr: "/usr/bin/env echo '/foo/bar/baz' 'baz' 'baz.hello' '/foo/bar' 'hello' 'a/b'\n",
}

#[cfg(not(windows))]
test! {
name: path_functions2,
justfile: r#"
justfile: r"
we := without_extension('/foo/bar/baz')
fs := file_stem('/foo/bar/baz.hello.ciao')
fn := file_name('/bar/baz.hello.ciao')
Expand All @@ -70,20 +70,20 @@ ext := extension('/foo/bar/baz.hello.ciao')
foo:
/usr/bin/env echo '{{we}}' '{{fs}}' '{{fn}}' '{{dir}}' '{{ext}}'
"#,
",
stdout: "/foo/bar/baz baz.hello baz.hello.ciao / ciao\n",
stderr: "/usr/bin/env echo '/foo/bar/baz' 'baz.hello' 'baz.hello.ciao' '/' 'ciao'\n",
}

#[cfg(not(windows))]
test! {
name: broken_without_extension_function,
justfile: r#"
justfile: r"
we := without_extension('')
foo:
/usr/bin/env echo '{{we}}'
"#,
",
stdout: "",
stderr: format!("{} {}\n{}\n{}\n{}\n{}\n",
"error: Call to function `without_extension` failed:",
Expand All @@ -98,12 +98,12 @@ foo:
#[cfg(not(windows))]
test! {
name: broken_extension_function,
justfile: r#"
justfile: r"
we := extension('')
foo:
/usr/bin/env echo '{{we}}'
"#,
",
stdout: "",
stderr: format!("{}\n{}\n{}\n{}\n{}\n",
"error: Call to function `extension` failed: Could not extract extension from ``",
Expand All @@ -117,12 +117,12 @@ foo:
#[cfg(not(windows))]
test! {
name: broken_extension_function2,
justfile: r#"
justfile: r"
we := extension('foo')
foo:
/usr/bin/env echo '{{we}}'
"#,
",
stdout: "",
stderr: format!("{}\n{}\n{}\n{}\n{}\n",
"error: Call to function `extension` failed: Could not extract extension from `foo`",
Expand All @@ -136,12 +136,12 @@ foo:
#[cfg(not(windows))]
test! {
name: broken_file_stem_function,
justfile: r#"
justfile: r"
we := file_stem('')
foo:
/usr/bin/env echo '{{we}}'
"#,
",
stdout: "",
stderr: format!("{}\n{}\n{}\n{}\n{}\n",
"error: Call to function `file_stem` failed: Could not extract file stem from ``",
Expand All @@ -155,12 +155,12 @@ foo:
#[cfg(not(windows))]
test! {
name: broken_file_name_function,
justfile: r#"
justfile: r"
we := file_name('')
foo:
/usr/bin/env echo '{{we}}'
"#,
",
stdout: "",
stderr: format!("{}\n{}\n{}\n{}\n{}\n",
"error: Call to function `file_name` failed: Could not extract file name from ``",
Expand All @@ -174,12 +174,12 @@ foo:
#[cfg(not(windows))]
test! {
name: broken_directory_function,
justfile: r#"
justfile: r"
we := parent_directory('')
foo:
/usr/bin/env echo '{{we}}'
"#,
",
stdout: "",
stderr: format!("{} {}\n{}\n{}\n{}\n{}\n",
"error: Call to function `parent_directory` failed:",
Expand All @@ -194,12 +194,12 @@ foo:
#[cfg(not(windows))]
test! {
name: broken_directory_function2,
justfile: r#"
justfile: r"
we := parent_directory('/')
foo:
/usr/bin/env echo '{{we}}'
"#,
",
stdout: "",
stderr: format!("{} {}\n{}\n{}\n{}\n{}\n",
"error: Call to function `parent_directory` failed:",
Expand Down Expand Up @@ -254,10 +254,10 @@ test! {

test! {
name: test_os_arch_functions_in_default,
justfile: r#"
justfile: r"
foo a=arch() o=os() f=os_family() n=num_cpus():
echo {{a}} {{o}} {{f}} {{n}}
"#,
",
stdout: format!("{} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
stderr: format!("echo {} {} {} {}\n", target::arch(), target::os(), target::family(), num_cpus::get()).as_str(),
}
Expand Down Expand Up @@ -664,7 +664,7 @@ fn uuid() {
#[test]
fn choose() {
Test::new()
.justfile(r#"x := choose('10', 'xXyYzZ')"#)
.justfile(r"x := choose('10', 'xXyYzZ')")
.args(["--evaluate", "x"])
.stdout_regex("^[X-Zx-z]{10}$")
.run();
Expand Down
16 changes: 9 additions & 7 deletions tests/interrupts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use {

fn kill(process_id: u32) {
unsafe {
libc::kill(process_id as i32, libc::SIGINT);
libc::kill(process_id.try_into().unwrap(), libc::SIGINT);
}
}

Expand All @@ -31,13 +31,15 @@ fn interrupt_test(arguments: &[&str], justfile: &str) {

let elapsed = start.elapsed();

if elapsed > Duration::from_secs(2) {
panic!("process returned too late: {elapsed:?}");
}
assert!(
elapsed <= Duration::from_secs(2),
"process returned too late: {elapsed:?}"
);

if elapsed < Duration::from_millis(100) {
panic!("process returned too early : {elapsed:?}");
}
assert!(
elapsed >= Duration::from_millis(100),
"process returned too early : {elapsed:?}"
);

assert_eq!(status.code(), Some(130));
}
Expand Down
4 changes: 1 addition & 3 deletions tests/invocation_directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ fn test_invocation_directory() {
failure = true;
}

if failure {
panic!("test failed");
}
assert!(!failure, "test failed");
}

#[test]
Expand Down
Loading

0 comments on commit 044b00a

Please sign in to comment.