Skip to content

Commit

Permalink
test: add tests for transition filegroup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Mar 30, 2022
1 parent 6a22c9a commit cee50ed
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 18 deletions.
18 changes: 0 additions & 18 deletions lib/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -95,24 +95,6 @@ bzl_library(
deps = ["//lib/private:diff_test"],
)

bzl_library(
name = "copy_file",
srcs = ["copy_file.bzl"],
visibility = ["//visibility:public"],
deps = ["//lib/private:copy_file"],
)

bzl_library(
name = "repositories",
srcs = ["repositories.bzl"],
visibility = ["//visibility:public"],
deps = [
"//lib/private:jq_toolchain",
"@bazel_tools//tools/build_defs/repo:http.bzl",
"@bazel_tools//tools/build_defs/repo:utils.bzl",
],
)

bzl_library(
name = "transitions",
srcs = ["transitions.bzl"],
Expand Down
59 changes: 59 additions & 0 deletions lib/tests/transitions/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
load("//lib:transitions.bzl", "platform_transition_filegroup")
load("@bazel_skylib//rules:diff_test.bzl", "diff_test")

platform(
name = "armv7_linux",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:armv7",
],
)

platform(
name = "x86_64_linux",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
)

config_setting(
name = "is_x86",
constraint_values = [
"@platforms//cpu:x86_64",
],
)

# Simple test fixture that produces something different depending on the
# target platform.
filegroup(
name = "platform_description",
srcs = select({
":is_x86": ["linux_x86.txt"],
"//conditions:default": ["linux_arm.txt"],
}),
)

platform_transition_filegroup(
name = "for_x86",
srcs = ["platform_description"],
target_platform = ":x86_64_linux",
)

platform_transition_filegroup(
name = "for_arm",
srcs = ["platform_description"],
target_platform = ":armv7_linux",
)

diff_test(
name = "test_x86",
file1 = "for_x86",
file2 = "linux_x86.txt",
)

diff_test(
name = "test_arm",
file1 = "for_arm",
file2 = "linux_arm.txt",
)
1 change: 1 addition & 0 deletions lib/tests/transitions/linux_arm.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Linux ARMv7
1 change: 1 addition & 0 deletions lib/tests/transitions/linux_x86.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Linux x86

0 comments on commit cee50ed

Please sign in to comment.