Skip to content

Commit

Permalink
run executable test case
Browse files Browse the repository at this point in the history
  • Loading branch information
jmelahman authored and filmil committed Nov 24, 2021
1 parent 8d5e169 commit c22437b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
17 changes: 15 additions & 2 deletions tests/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
load("@bazel_bats//:rules.bzl", "bats_test")

sh_binary(
name = "exit_with_input_bin",
srcs = ["exit_with_input"],
)

bats_test(
name = "exit_with_input_test",
srcs = ["exit_with_input.bats"],
deps = [
":exit_with_input_bin",
],
)

sh_library(
name = "helper",
srcs = ["helper.bash"],
name = "helper",
srcs = ["helper.bash"],
)

bats_test(
Expand Down
2 changes: 2 additions & 0 deletions tests/exit_with_input
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
exit $1
13 changes: 13 additions & 0 deletions tests/exit_with_input.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bats

PATH_TO_EXIT_WITH_INPUT="tests/exit_with_input"

@test "can run executable" {
run "${PATH_TO_EXIT_WITH_INPUT}" 1
[ $status -eq 1 ]
}

@test "can run executable with different return code" {
run "${PATH_TO_EXIT_WITH_INPUT}" 2
[ $status -eq 2 ]
}

0 comments on commit c22437b

Please sign in to comment.