Skip to content

Commit

Permalink
Add analysis test
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Nov 26, 2024
1 parent fec26f9 commit 05813e4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ use_repo(compat, "compatibility_proxy")
bazel_dep(name = "rules_pkg", version = "0.9.1", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.7.1", dev_dependency = True)
bazel_dep(name = "rules_shell", version = "0.2.0", dev_dependency = True)
bazel_dep(name = "rules_testing", version = "0.7.0", dev_dependency = True)

test_repositories = use_extension("//test:repositories.bzl", "test_repositories_ext", dev_dependency = True)
use_repo(test_repositories, "guava", "truth")
7 changes: 7 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ load("@stardoc//:setup.bzl", "stardoc_repositories")

stardoc_repositories()

http_archive(
name = "rules_testing",
sha256 = "28c2d174471b587bf0df1fd3a10313f22c8906caf4050f8b46ec4648a79f90c3",
strip_prefix = "rules_testing-0.7.0",
url = "https://github.com/bazelbuild/rules_testing/releases/download/v0.7.0/rules_testing-v0.7.0.tar.gz",
)

load("//test:repositories.bzl", "test_repositories")

test_repositories()
5 changes: 5 additions & 0 deletions test/analysis/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
load(":bootclasspath_tests.bzl", "bootclasspath_tests")

bootclasspath_tests(
name = "bootclasspath_tests",
)
25 changes: 25 additions & 0 deletions test/analysis/bootclasspath_tests.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Tests for the bootclasspath rule."""

load("@rules_testing//lib:analysis_test.bzl", "analysis_test", "test_suite")
load("@rules_testing//lib:truth.bzl", "subjects")

def _test_utf_8_environment(name):
analysis_test(
name = name,
impl = _test_utf_8_environment_impl,
target = Label("//toolchains:platformclasspath"),
)

def _test_utf_8_environment_impl(env, target):
for action in target.actions:
env_subject = env.expect.where(action = action).that_dict(action.env)
env_subject.keys().contains("LC_CTYPE")
env_subject.get("LC_CTYPE", factory = subjects.str).contains("UTF-8")

def bootclasspath_tests(name):
test_suite(
name = name,
tests = [
_test_utf_8_environment,
],
)

0 comments on commit 05813e4

Please sign in to comment.