-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Buildkite config and tests for Bazelisk.
- Loading branch information
Showing
6 changed files
with
100 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
platforms: | ||
ubuntu1404: | ||
test_targets: | ||
- //:bazelisk_test | ||
ubuntu1604: | ||
test_targets: | ||
- //:bazelisk_test | ||
ubuntu1804: | ||
test_targets: | ||
- //:bazelisk_test | ||
macos: | ||
test_targets: | ||
- //:bazelisk_test | ||
windows: | ||
test_targets: | ||
- //:bazelisk_test | ||
test_flags: | ||
- --test_env=PROCESSOR_ARCHITECTURE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
py_library( | ||
name = "bazelisk_lib", | ||
srcs = ["bazelisk.py"], | ||
) | ||
|
||
py_test( | ||
name = "bazelisk_test", | ||
srcs = ["bazelisk_test.py"], | ||
deps = [":bazelisk_lib"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
import os | ||
import unittest | ||
import subprocess | ||
import tempfile | ||
|
||
import bazelisk | ||
|
||
|
||
def execute_bazel(bazel_path, argv): | ||
return subprocess.check_output( | ||
[bazel_path] + argv, close_fds=os.name != 'nt', | ||
stderr=subprocess.STDOUT).decode("utf-8") | ||
|
||
|
||
class TestBazelisk(unittest.TestCase): | ||
"""Integration tests for Bazelisk.""" | ||
|
||
def setUp(self): | ||
# Override Bazelisk's default function to execute Bazel, so that we can grab the output. | ||
bazelisk.execute_bazel = execute_bazel | ||
os.environ["BAZELISK_HOME"] = tempfile.mkdtemp( | ||
dir=os.environ["TEST_TMPDIR"]) | ||
|
||
def test_bazel_version(self): | ||
output = bazelisk.main(["bazelisk", "version"]) | ||
self.assertTrue("Build label" in output) | ||
|
||
def test_bazel_version_from_environment(self): | ||
os.environ["USE_BAZEL_VERSION"] = "0.20.0" | ||
try: | ||
output = bazelisk.main(["bazelisk", "version"]) | ||
finally: | ||
del os.environ["USE_BAZEL_VERSION"] | ||
self.assertTrue("Build label: 0.20.0" in output) | ||
|
||
def test_bazel_version_from_file(self): | ||
with open("WORKSPACE", "w") as f: | ||
pass | ||
with open(".bazelversion", "w") as f: | ||
f.write("0.19.0") | ||
try: | ||
output = bazelisk.main(["bazelisk", "version"]) | ||
finally: | ||
os.unlink("WORKSPACE") | ||
os.unlink(".bazelversion") | ||
self.assertTrue("Build label: 0.19.0" in output) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |