Skip to content

Commit

Permalink
[tests] Add a test of compiler gym version number.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisCummins committed Apr 2, 2021
1 parent 66fbf5c commit 32fa3ff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ py_test(
name = "version_test",
timeout = "short",
srcs = ["version_test.py"],
data = ["//:VERSION"],
deps = [
":test_main",
"//compiler_gym",
"//tests/pytest_plugins:common",
],
)
5 changes: 5 additions & 0 deletions tests/pytest_plugins/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
not sys.platform.lower().startswith("darwin"), reason="macOS only"
)

# Decorator to mark a test as skipped if not running under bazel.
bazel_only = pytest.mark.skipif(
os.environ.get("TEST_WORKSPACE", "") == "", reason="bazel only"
)


@pytest.fixture(scope="function")
def tmpwd() -> Path:
Expand Down
10 changes: 10 additions & 0 deletions tests/version_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import pytest

import compiler_gym
from compiler_gym.util.runfiles_path import runfiles_path
from packaging import version
from tests.pytest_plugins.common import bazel_only
from tests.test_main import main

# Marker to skip a test if running under bazel.
Expand All @@ -33,5 +35,13 @@ def test_setuptools_version():
assert version == compiler_gym.__version__


@bazel_only
def test_expected_version():
"""Test that embedded compiler gym version matches VERSION file."""
with open(runfiles_path("VERSION")) as f:
version = f.read().strip()
assert version == compiler_gym.__version__


if __name__ == "__main__":
main()

0 comments on commit 32fa3ff

Please sign in to comment.