Skip to content

Commit

Permalink
Add regression tests for onlyargs_derive
Browse files Browse the repository at this point in the history
  • Loading branch information
parasyte committed Feb 19, 2024
1 parent 86ef701 commit 2202aea
Show file tree
Hide file tree
Showing 38 changed files with 464 additions and 0 deletions.
155 changes: 155 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions onlyargs_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ license = "MIT"
[lib]
proc-macro = true

[[test]]
name = "compile_and_fail"
path = "compile_tests/compiler.rs"

[dependencies]
myn = "0.2.1"
onlyargs = { version = "0.1", path = ".." }

[dev-dependencies]
trybuild = "1"
41 changes: 41 additions & 0 deletions onlyargs_derive/compile_tests/compiler.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#[test]
fn compile_tests() {
let t = trybuild::TestCases::new();
t.pass("compile_tests/default_bool_false.rs");
t.pass("compile_tests/default_bool_true.rs");
t.pass("compile_tests/default_f32.rs");
t.pass("compile_tests/default_f64.rs");
t.pass("compile_tests/default_i8.rs");
t.pass("compile_tests/default_i128.rs");
t.pass("compile_tests/default_isize.rs");
// TODO: Negatives are not supported yet!
// t.pass("compile_tests/default_negative_i8.rs");
// t.pass("compile_tests/default_negative_i128.rs");
// t.pass("compile_tests/default_negative_isize.rs");
t.pass("compile_tests/default_osstring.rs");
t.pass("compile_tests/default_pathbuf.rs");
t.pass("compile_tests/default_string.rs");
t.pass("compile_tests/default_u8.rs");
t.pass("compile_tests/default_u128.rs");
t.pass("compile_tests/default_usize.rs");

t.pass("compile_tests/positional_f32.rs");
t.pass("compile_tests/positional_f64.rs");
t.pass("compile_tests/positional_i8.rs");
t.pass("compile_tests/positional_i128.rs");
t.pass("compile_tests/positional_isize.rs");
t.pass("compile_tests/positional_osstring.rs");
t.pass("compile_tests/positional_pathbuf.rs");
t.pass("compile_tests/positional_string.rs");
t.pass("compile_tests/positional_u8.rs");
t.pass("compile_tests/positional_usize.rs");

t.pass("compile_tests/empty.rs");
t.pass("compile_tests/optional.rs");
t.pass("compile_tests/struct_doc_comment.rs");
t.pass("compile_tests/struct_footer.rs");

t.compile_fail("compile_tests/conflicting_short_name.rs");
t.pass("compile_tests/manual_short_name.rs");
t.pass("compile_tests/ignore_short_name.rs");
}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/conflicting_short_name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
min: i32,
max: i32,
}

fn main() {}
5 changes: 5 additions & 0 deletions onlyargs_derive/compile_tests/conflicting_short_name.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
error: Only one short arg is allowed. `-m` also used on field `min`
--> compile_tests/conflicting_short_name.rs:4:5
|
4 | max: i32,
| ^^^
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_bool_false.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(false)]
maybe: bool,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_bool_true.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(true)]
maybe: bool,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_f32.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(42.123)]
width: f32,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_f64.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(42.123)]
width: f64,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_i128.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(42)]
width: i128,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_i8.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(42)]
width: i8,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_isize.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(42)]
width: isize,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_negative_i128.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(-42)]
width: i128,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_negative_i8.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(-42)]
width: i8,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_negative_isize.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(-42)]
width: isize,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_osstring.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default("foo bar")]
name: std::ffi::OsString,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_pathbuf.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default("./foo/bar")]
path: std::path::PathBuf,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_string.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default("foo bar")]
name: String,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_u128.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(42)]
width: u128,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_u8.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(42)]
width: u8,
}

fn main() {}
7 changes: 7 additions & 0 deletions onlyargs_derive/compile_tests/default_usize.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
#[default(42)]
width: usize,
}

fn main() {}
4 changes: 4 additions & 0 deletions onlyargs_derive/compile_tests/empty.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {}

fn main() {}
9 changes: 9 additions & 0 deletions onlyargs_derive/compile_tests/ignore_short_name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#[derive(Debug, onlyargs_derive::OnlyArgs)]
struct Args {
min: i32,

#[long]
max: i32,
}

fn main() {}
Loading

0 comments on commit 2202aea

Please sign in to comment.