github.com/0xKiwi/rules_go@v0.24.3/tests/core/starlark/common_tests.bzl (about) 1 load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest") 2 load("@io_bazel_rules_go//go/private:common.bzl", "has_shared_lib_extension") 3 4 def _versioned_shared_libraries_test(ctx): 5 env = unittest.begin(ctx) 6 7 # See //src/test/java/com/google/devtools/build/lib/rules/cpp:CppFileTypesTest.java 8 # for the corresponding native C++ rules tests. 9 asserts.true(env, has_shared_lib_extension("somelibrary.so")) 10 asserts.true(env, has_shared_lib_extension("somelibrary.so.2")) 11 asserts.true(env, has_shared_lib_extension("somelibrary.so.20")) 12 asserts.true(env, has_shared_lib_extension("somelibrary.so.20.2")) 13 asserts.true(env, has_shared_lib_extension("a/somelibrary.so.2")) 14 asserts.true(env, has_shared_lib_extension("somelibrary✅.so.2")) 15 asserts.true(env, has_shared_lib_extension("somelibrary✅.so.2.1")) 16 asserts.false(env, has_shared_lib_extension("somelibrary.so.e")) 17 asserts.false(env, has_shared_lib_extension("xx.1")) 18 asserts.false(env, has_shared_lib_extension("somelibrary.so.2e")) 19 asserts.false(env, has_shared_lib_extension("somelibrary.so.e2")) 20 asserts.false(env, has_shared_lib_extension("somelibrary.so.20.e2")) 21 asserts.false(env, has_shared_lib_extension("somelibrary.a.2")) 22 asserts.false(env, has_shared_lib_extension("somelibrary.a..2")) 23 asserts.false(env, has_shared_lib_extension("somelibrary.so.2.")) 24 asserts.false(env, has_shared_lib_extension("somelibrary.so.")) 25 asserts.false(env, has_shared_lib_extension("somelibrary.so.2🚫")) 26 asserts.false(env, has_shared_lib_extension("somelibrary.so.🚫2")) 27 asserts.false(env, has_shared_lib_extension("somelibrary.so🚫.2.0")) 28 29 return unittest.end(env) 30 31 versioned_shared_libraries_test = unittest.make(_versioned_shared_libraries_test) 32 33 def common_test_suite(): 34 """Creates the test targets and test suite for common.bzl tests.""" 35 unittest.suite( 36 "common_tests", 37 versioned_shared_libraries_test, 38 )