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 efd781b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
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 efd781b

Please sign in to comment.