Skip to content

Commit

Permalink
Refactored other tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchieAtkinson committed Jan 12, 2025
1 parent b27a26a commit 7d8c264
Showing 1 changed file with 149 additions and 114 deletions.
263 changes: 149 additions & 114 deletions tests/no_exit_message.rs
Original file line number Diff line number Diff line change
@@ -1,133 +1,168 @@
use super::*;

test! {
name: recipe_exit_message_suppressed,
justfile: r#"
# This is a doc comment
[no-exit-message]
hello:
@echo "Hello, World!"
@exit 100
"#,
stdout: "Hello, World!\n",
stderr: "",
status: 100,
#[test]
fn recipe_exit_message_suppressed() {
Test::new()
.justfile(
r#"
# This is a doc comment
[no-exit-message]
hello:
@echo "Hello, World!"
@exit 100
"#,
)
.stdout("Hello, World!\n")
.status(100)
.run();
}

test! {
name: silent_recipe_exit_message_suppressed,
justfile: r#"
# This is a doc comment
[no-exit-message]
@hello:
echo "Hello, World!"
exit 100
"#,
stdout: "Hello, World!\n",
stderr: "",
status: 100,

#[test]
fn silent_recipe_exit_message_suppressed() {
Test::new()
.justfile(
r#"
# This is a doc comment
[no-exit-message]
@hello:
echo "Hello, World!"
exit 100
"#,
)
.stdout("Hello, World!\n")
.status(100)
.run();
}

test! {
name: recipe_has_doc_comment,
justfile: r"
# This is a doc comment
[no-exit-message]
hello:
@exit 100
",
args: ("--list"),
stdout: "
Available recipes:
hello # This is a doc comment
",
#[test]
fn recipe_has_doc_comment() {
Test::new()
.justfile(
"
# This is a doc comment
[no-exit-message]
hello:
@exit 100
",
)
.arg("--list")
.stdout("
Available recipes:
hello # This is a doc comment
",
)
.run();
}

test! {
name: unknown_attribute,
justfile: r"
# This is a doc comment
[unknown-attribute]
hello:
@exit 100
",
stderr: r"
error: Unknown attribute `unknown-attribute`
β€”β€”β–Ά justfile:2:2
β”‚
2 β”‚ [unknown-attribute]
β”‚ ^^^^^^^^^^^^^^^^^
",
status: EXIT_FAILURE,
#[test]
fn unknown_attribute() {
Test::new()
.justfile(
"
# This is a doc comment
[unknown-attribute]
hello:
@exit 100
",
)
.stderr("
error: Unknown attribute `unknown-attribute`
β€”β€”β–Ά justfile:2:2
β”‚
2 β”‚ [unknown-attribute]
β”‚ ^^^^^^^^^^^^^^^^^
",
)
.status(EXIT_FAILURE)
.run();
}

test! {
name: empty_attribute,
justfile: r"
# This is a doc comment
[]
hello:
@exit 100
",
stderr: r"
error: Expected identifier, but found ']'
β€”β€”β–Ά justfile:2:2
β”‚
2 β”‚ []
β”‚ ^
",
status: EXIT_FAILURE,
#[test]
fn empty_attribute() {
Test::new()
.justfile(
"
# This is a doc comment
[]
hello:
@exit 100
",
)
.stderr("
error: Expected identifier, but found ']'
β€”β€”β–Ά justfile:2:2
β”‚
2 β”‚ []
β”‚ ^
",
)
.status(EXIT_FAILURE)
.run();
}

test! {
name: extraneous_attribute_before_comment,
justfile: r"
[no-exit-message]
# This is a doc comment
hello:
@exit 100
",
stderr: r"
error: Extraneous attribute
β€”β€”β–Ά justfile:1:1
β”‚
1 β”‚ [no-exit-message]
β”‚ ^
",

status: EXIT_FAILURE,

#[test]
fn extraneous_attribute_before_comment() {
Test::new()
.justfile(
"
[no-exit-message]
# This is a doc comment
hello:
@exit 100
",
)
.stderr("
error: Extraneous attribute
β€”β€”β–Ά justfile:1:1
β”‚
1 β”‚ [no-exit-message]
β”‚ ^
",
)
.status(EXIT_FAILURE)
.run();
}

test! {
name: extraneous_attribute_before_empty_line,
justfile: r"
[no-exit-message]
hello:
@exit 100
",
stderr: "
error: Extraneous attribute
β€”β€”β–Ά justfile:1:1
β”‚
1 β”‚ [no-exit-message]
β”‚ ^
",
status: EXIT_FAILURE,
#[test]
fn extraneous_attribute_before_empty_line() {
Test::new()
.justfile(
"
[no-exit-message]
hello:
@exit 100
",
)
.stderr("
error: Extraneous attribute
β€”β€”β–Ά justfile:1:1
β”‚
1 β”‚ [no-exit-message]
β”‚ ^
",
)
.status(EXIT_FAILURE)
.run();
}

test! {
name: shebang_exit_message_suppressed,
justfile: r"
[no-exit-message]
hello:
#!/usr/bin/env bash
echo 'Hello, World!'
exit 100
",
stdout: "Hello, World!\n",
stderr: "",
status: 100,
#[test]
fn shebang_exit_message_suppressed() {
Test::new()
.justfile(
r#"
[no-exit-message]
hello:
#!/usr/bin/env bash
echo 'Hello, World!'
exit 100
"#,
)
.stdout("Hello, World!\n")
.status(100)
.run();
}

#[test]
Expand Down

0 comments on commit 7d8c264

Please sign in to comment.