refactoring testball case to make it more readable

This commit is contained in:
thibhero 2025-03-06 20:59:56 -05:00
parent fa4e2bad6e
commit f4d93e19b8

View File

@ -135,11 +135,17 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
case name
when /^testball/
case name
when "testball4", "testball5", "testball2"
when "testball4", "testball5"
prefix = name
program_name = name
when "testball2"
prefix = name
program_name = "test"
else
prefix = "testball"
program_name = "test"
end
tarball_name = "#{prefix}-0.1#{'-linux' if OS.linux?}.tbz"
tarball = TEST_FIXTURE_DIR / "tarballs/#{tarball_name}"
@ -151,14 +157,13 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
option "with-foo", "Build with foo"
#{bottle_block}
def install
(prefix/"foo"/"#{prefix}").write("#{prefix}") if build.with? "foo"
(prefix/"foo"/"#{program_name}").write("#{program_name}") if build.with? "foo"
prefix.install Dir["*"]
(buildpath/"#{prefix}.c").write \\
"#include <stdio.h>\\nint main(){printf(\\"#{prefix}\\");return 0;}"
(buildpath/"#{program_name}.c").write \
"#include <stdio.h>\\nint main(){printf(\\"#{program_name}\\");return 0;}"
bin.mkpath
system ENV.cc, "#{prefix}.c", "-o", bin/"#{prefix}"
system ENV.cc, "#{program_name}.c", "-o", bin/"#{program_name}"
end
#{content}