Skip to content

Commit

Permalink
integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmelahman authored and filmil committed Nov 24, 2021
1 parent 2be16d8 commit 60cab73
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 0 deletions.
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
integration/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
# Ignore all bazel-* symlinks. There is no full list since this can change
# based on the name of the directory bazel is cloned into.
/bazel-*
/integration/bazel-*
38 changes: 38 additions & 0 deletions integration/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
load("@bazel_bats//:rules.bzl", "bats_test")

bats_test(
name = "hello_world_test",
srcs = ["hello_world.bats"],
env = {
"PROGRAM": "hello_world",
"LOCATED": "$(location :dummy)",
},
deps = [":dummy"],
)

bats_test(
name = "hello_world_twofiles_test",
srcs = [
"hello_world_1.bats",
"hello_world_2.bats",
],
)

bats_test(
name = "hello_world_twofiles_1_test",
srcs = [
"hello_world_1.bats",
],
)

bats_test(
name = "hello_world_twofiles_2_test",
srcs = [
"hello_world_2.bats",
],
)

filegroup(
name = "dummy",
srcs = ["dummy.txt"],
)
23 changes: 23 additions & 0 deletions integration/WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
workspace(name = "bazel_bats_integration")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

BAZEL_BATS_VERSION = "0.29.1"
HEAD = "75dea0bc4d15d48a4238ad2143e998509c0cb3e4"

http_archive(
name = "bazel_bats",
# TODO: Tag and release HEAD.
# strip_prefix = "bazel-bats-%s" % BAZEL_BATS_VERSION,
strip_prefix = "bazel-bats-%s" % HEAD,
urls = [
# TODO: Tag and release HEAD.
# "https://github.com/jmelahman/bazel-bats/archive/refs/tags/v%s.tar.gz" % BAZEL_BATS_VERSION,
"https://github.com/jmelahman/bazel-bats/archive/%s.tar.gz" % HEAD,
],
sha256 = "e57d61da26bbb5428e8162da4fa2432d85abc2530b6211dd2d096d75be18d9fb",
)

load("@bazel_bats//:deps.bzl", "bazel_bats_dependencies")

bazel_bats_dependencies()
1 change: 1 addition & 0 deletions integration/dummy.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#empty file
15 changes: 15 additions & 0 deletions integration/hello_world.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bats

@test "addition using bc" {
result="$(echo 4)"
[ "$result" -eq 4 ]
}

@test "Test program name" {
[ "${PROGRAM}" == "hello_world" ]
}

@test "Test program name with location" {
echo "Location: ${LOCATED}"
[ "${LOCATED}" == "./dummy.txt" ]
}
7 changes: 7 additions & 0 deletions integration/hello_world_1.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bats

@test "addition using bc" {
result="$(echo 4)"
[ "$result" -eq 4 ]
}

7 changes: 7 additions & 0 deletions integration/hello_world_2.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bats

@test "addition using bc" {
result="$(echo 4)"
[ "$result" -eq 4 ]
}

0 comments on commit 60cab73

Please sign in to comment.