Skip to content

Commit

Permalink
test: convert only py_test to starlark (#843)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle authored and gregmagolan committed Jun 11, 2019
1 parent 8e080a6 commit 9a95730
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 57 deletions.
5 changes: 5 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

# Needed for starlark unit testing
load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

#
# Install npm dependencies for tests
#
Expand Down
11 changes: 2 additions & 9 deletions internal/common/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load(":check_version_test.bzl", "check_version_test_suite")

licenses(["notice"]) # Apache 2.0

Expand All @@ -27,15 +28,7 @@ bzl_library(
# Exported to be consumed for generating skydoc.
exports_files(["check_bazel_version.bzl"])

py_test(
name = "check_version_test",
size = "small",
srcs = ["check_version_test.py"],
data = [":check_version.bzl"],
# Explicitly pin to Python 2 to avoid toolchain configuration
# TODO(alexeagle): switch to starlark test mechanism
python_version = "PY2",
)
check_version_test_suite()

filegroup(
name = "package_contents",
Expand Down
20 changes: 20 additions & 0 deletions internal/common/check_version_test.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"Unit tests for check_version.bzl"

load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
load(":check_version.bzl", "check_version", "check_version_range")

def _check_version_test_impl(ctx):
env = unittest.begin(ctx)
asserts.equals(env, False, check_version("1.2.2", "1.2.3"))
asserts.equals(env, True, check_version("1.12.3", "1.2.1"))
asserts.equals(env, True, check_version("0.8.0rc2", "0.8.0"))
asserts.equals(env, True, check_version_range("1.2.2", "1.2.1", "1.2.3"))
asserts.equals(env, False, check_version_range("1.2.0", "1.2.1", "1.2.3"))
asserts.equals(env, False, check_version_range("1.2.4", "1.2.1", "1.2.3"))

return unittest.end(env)

check_version_test = unittest.make(_check_version_test_impl)

def check_version_test_suite():
unittest.suite("check_version_tests", check_version_test)
48 changes: 0 additions & 48 deletions internal/common/check_version_test.py

This file was deleted.

0 comments on commit 9a95730

Please sign in to comment.