Skip to content

Commit

Permalink
test: more tests for find_jobserver_auth
Browse files Browse the repository at this point in the history
  • Loading branch information
weihanglo authored and petrochenkov committed Feb 5, 2024
1 parent 00ea8f0 commit cc54e70
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,21 +614,39 @@ fn no_helper_deadlock() {
#[test]
fn test_find_jobserver_auth() {
let cases = [
("--jobserver-auth=auth-a --jobserver-auth=auth-b", "auth-b"),
("--jobserver-auth=auth-b --jobserver-auth=auth-a", "auth-a"),
("--jobserver-fds=fds-a --jobserver-fds=fds-b", "fds-b"),
("--jobserver-fds=fds-b --jobserver-fds=fds-a", "fds-a"),
("", None),
("-j2", None),
("-j2 --jobserver-auth=3,4", Some("3,4")),
("--jobserver-auth=3,4 -j2", Some("3,4")),
("--jobserver-auth=3,4", Some("3,4")),
("--jobserver-auth=fifo:/myfifo", Some("fifo:/myfifo")),
("--jobserver-auth=", Some("")),
("--jobserver-auth", None),
("--jobserver-fds=3,4", Some("3,4")),
("--jobserver-fds=fifo:/myfifo", Some("fifo:/myfifo")),
("--jobserver-fds=", Some("")),
("--jobserver-fds", None),
(
"--jobserver-auth=auth-a --jobserver-auth=auth-b",
Some("auth-b"),
),
(
"--jobserver-auth=auth-b --jobserver-auth=auth-a",
Some("auth-a"),
),
("--jobserver-fds=fds-a --jobserver-fds=fds-b", Some("fds-b")),
("--jobserver-fds=fds-b --jobserver-fds=fds-a", Some("fds-a")),
(
"--jobserver-auth=auth-a --jobserver-fds=fds-a --jobserver-auth=auth-b",
"auth-b",
Some("auth-b"),
),
(
"--jobserver-fds=fds-a --jobserver-auth=auth-a --jobserver-fds=fds-b",
"auth-a",
Some("auth-a"),
),
];
for (var, expected) in cases {
let actual = find_jobserver_auth(var).unwrap();
let actual = find_jobserver_auth(var);
assert_eq!(
actual, expected,
"expect {expected:?}, got {actual:?}, input `{var:?}`"
Expand Down

0 comments on commit cc54e70

Please sign in to comment.