|
3 | 3 | "ruby_binary", |
4 | 4 | "ruby_test", |
5 | 5 | ) |
| 6 | +load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar") |
| 7 | +load("@io_bazel_rules_docker//container:container.bzl", "container_image") |
6 | 8 |
|
7 | 9 | # Checks if args are correctly passed to the ruby script. |
8 | 10 | ruby_test( |
@@ -69,13 +71,13 @@ genrule( |
69 | 71 | "echo '#!/bin/sh -e' > $@", |
70 | 72 | "echo true >> $@", |
71 | 73 | ]), |
| 74 | + message = "Running ruby_bin in genrule", |
72 | 75 | output_to_bindir = 1, |
73 | 76 | tools = [ |
74 | 77 | "args_check.rb", |
75 | 78 | "@org_ruby_lang_ruby_host//:ruby_bin", |
76 | 79 | "@org_ruby_lang_ruby_host//:runtime", |
77 | 80 | ], |
78 | | - message = "Running ruby_bin in genrule", |
79 | 81 | ) |
80 | 82 |
|
81 | 83 | sh_test( |
@@ -154,15 +156,15 @@ sh_test( |
154 | 156 |
|
155 | 157 | genrule( |
156 | 158 | name = "dummy_genfile_load_path_in_runfiles", |
157 | | - message = "Running :load_path_in_runfiles in genrule", |
158 | 159 | outs = ["load_path_in_runfiles_test_5a.sh"], |
159 | | - tools = [":load_path_in_runfiles"], |
160 | 160 | cmd = " && ".join([ |
161 | 161 | "$(location :load_path_in_runfiles)", |
162 | 162 | "echo '#!/bin/sh -e' > $@", |
163 | 163 | "echo 'true' >> $@", |
164 | 164 | ]), |
165 | 165 | executable = True, |
| 166 | + message = "Running :load_path_in_runfiles in genrule", |
| 167 | + tools = [":load_path_in_runfiles"], |
166 | 168 | ) |
167 | 169 |
|
168 | 170 | # TODO(yugui) Add a test for case 6a. |
@@ -225,3 +227,40 @@ ruby_test( |
225 | 227 | }), |
226 | 228 | main = "ext_test.rb", |
227 | 229 | ) |
| 230 | + |
| 231 | +## Containerization test |
| 232 | + |
| 233 | +# TODO(yugui) Make it easier to build a tar with the right runfiles structure |
| 234 | +pkg_tar( |
| 235 | + name = "load_path_in_runfiles_container_layer", |
| 236 | + srcs = [":load_path_in_runfiles"], |
| 237 | + include_runfiles = True, |
| 238 | + package_dir = "/app", |
| 239 | + remap_paths = { |
| 240 | + "ruby": "load_path_in_runfiles.runfiles/bazelruby_ruby_rules/ruby", |
| 241 | + ".": "load_path_in_runfiles.runfiles/", |
| 242 | + }, |
| 243 | + strip_prefix = "dummy", |
| 244 | + symlinks = { |
| 245 | + "/app/load_path_in_runfiles.runfiles/bazelruby_ruby_rules/external": "/app/load_path_in_runfiles.runfiles", |
| 246 | + "/app/load_path_in_runfiles": "/app/load_path_in_runfiles.runfiles/bazelruby_ruby_rules/ruby/tests/load_path_in_runfiles", |
| 247 | + }, |
| 248 | +) |
| 249 | + |
| 250 | +container_image( |
| 251 | + name = "load_path_in_runfiles_container_image", |
| 252 | + base = "@ruby_base_container//image", |
| 253 | + entrypoint = ["/app/load_path_in_runfiles"], |
| 254 | + tars = [":load_path_in_runfiles_container_layer"], |
| 255 | +) |
| 256 | + |
| 257 | +sh_test( |
| 258 | + name = "load_path_in_runfiles_container_test", |
| 259 | + srcs = ["container_test.sh"], |
| 260 | + args = [ |
| 261 | + "$(location :load_path_in_runfiles_container_image)", |
| 262 | + "bazel/ruby/tests:load_path_in_runfiles_container_image", |
| 263 | + ], |
| 264 | + data = [":load_path_in_runfiles_container_image"], |
| 265 | + tags = ["docker"], |
| 266 | +) |
0 commit comments