Skip to content

Commit 9b1a2a0

Browse files
add test case for installed executable
1 parent f6762ba commit 9b1a2a0

6 files changed

Lines changed: 19 additions & 9 deletions

File tree

examples/git_gem/.bazelversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8.5.1
1+
../../.bazelversion

examples/git_gem/BUILD

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
load("@rules_ruby//ruby:defs.bzl", "rb_binary", "rb_test")
22

3-
# A simple binary that uses the Git-sourced hello_world gem
43
rb_binary(
54
name = "greeter",
65
srcs = ["greeter.rb"],
76
deps = ["@bundle"],
87
)
98

10-
# Test that verifies the Git-sourced gem works correctly
119
rb_test(
1210
name = "greeter_test",
1311
srcs = ["greeter_test.rb"],
1412
deps = ["@bundle"],
1513
)
14+
15+
rb_test(
16+
name = "hello_world_bin_test",
17+
main = "hello_world_bin_test.rb",
18+
srcs = ["hello_world_bin_test.rb"],
19+
args = ["$(rlocationpath @bundle//bin:hello_world)"],
20+
data = ["@bundle//bin:hello_world"],
21+
)

examples/git_gem/Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ source "https://rubygems.org"
44

55
# Reference hello_world gem from the rules_ruby repository on GitHub
66
gem "hello_world",
7-
git: "https://github.com/bazel-contrib/rules_ruby.git",
7+
git: "https://github.com/withered-magic/rules_ruby.git",
88
glob: "examples/deep_gem/hello_world/*.gemspec",
9-
ref: "2c98fcaf4d60007a351c6e9a15678d64e1cc4cda"
9+
ref: "f6762ba5610170f69f28cdd5523697c357ed95e2"

examples/git_gem/Gemfile.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
GIT
2-
remote: https://github.com/bazel-contrib/rules_ruby.git
3-
revision: 2c98fcaf4d60007a351c6e9a15678d64e1cc4cda
4-
ref: 2c98fcaf4d60007a351c6e9a15678d64e1cc4cda
2+
remote: https://github.com/withered-magic/rules_ruby.git
3+
revision: f6762ba5610170f69f28cdd5523697c357ed95e2
4+
ref: f6762ba5610170f69f28cdd5523697c357ed95e2
55
glob: examples/deep_gem/hello_world/*.gemspec
66
specs:
77
hello_world (0.0.0)

examples/git_gem/MODULE.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ ruby.toolchain(
1212
version_file = "//:.ruby-version",
1313
)
1414
use_repo(ruby, "ruby")
15-
1615
ruby.bundle_fetch(
1716
name = "bundle",
1817
gemfile = "//:Gemfile",
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
binary = File.join(ENV["TEST_SRCDIR"], ARGV[0])
2+
output = `#{binary} 2>&1`
3+
raise "Binary exited with code #{$?.exitstatus}: #{output}" unless $?.success?
4+
raise "Expected 'Hello, World', got '#{output.strip}'" unless output.include?("Hello, World")
5+
puts "PASS: Got expected output 'Hello, World'"

0 commit comments

Comments
 (0)