Skip to content

Commit

Permalink
0.8.6 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Aug 31, 2024
1 parent d2e15dc commit 0d5ad7a
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 50 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ set(WITH_PATCHELF OFF)
if("${OSTYPE_TXT}" MATCHES "^linux-gnu.*")
set(IS_GNU ON)
if(REMOVE_GLIBC_PRIVATE)
set(WITH_PATCHELF ON)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(WITH_PATCHELF ON)
else()
message(WARNING "Elf file patching is supported for GNU toolchain only. 'patchelf' setting ignored")
endif()
endif(REMOVE_GLIBC_PRIVATE)
elseif("${OSTYPE_TXT}" MATCHES "^linux-musl.*")
set(IS_MUSL ON)
Expand Down Expand Up @@ -187,9 +191,7 @@ set(DATA_RES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/resources)
# External projects

if ("-${RUBY_VER}" STREQUAL "-" OR "-${RUBY_HASH}" STREQUAL "-")
set(RUBY_VER "3.1.4")
set(RUBY_HASH "a3d55879a0dfab1d7141fdf10d22a07dbf8e5cdc4415da1bde06127d5cc3c7b6")
message(STATUS "Using default Ruby version ${RUBY_VER}")
message(FATAL_ERROR "Ruby version is not specified")
endif()

set(RUBY_NAME ruby)
Expand Down
2 changes: 1 addition & 1 deletion exe/tebako-packager
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ begin
"tebako-packager finalize command expects 7 arguments, #{ARGV.length} has been provided."
end
ruby_ver = Tebako::RubyVersion.new(ARGV[4])
with_patchelf = ARGV[6].casecmp("ON") == 0 || ARGV[6].casecmp("YES") == 0
with_patchelf = ARGV[6].casecmp("ON").zero? || ARGV[6].casecmp("YES").zero?
Tebako::Packager.finalize(ARGV[1], ARGV[2], ARGV[3], ruby_ver, with_patchelf ? ARGV[5] : nil)
else
raise Tebako::Error, "tebako-packager cannot process #{ARGV[0]} command"
Expand Down
4 changes: 2 additions & 2 deletions lib/tebako/build_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def ncores
out, st = Open3.capture2e("nproc", "--all")
end

if st.exitstatus.zero?
if !st.signaled? && st.exitstatus.zero?
out.strip.to_i
else
4
Expand All @@ -49,7 +49,7 @@ def ncores
def run_with_capture(args)
puts " ... @ #{args.join(" ")}"
out, st = Open3.capture2e(*args)
raise Tebako::Error, "Failed to run #{args.join(" ")} (#{st}):\n #{out}" unless st.exitstatus.zero?
raise Tebako::Error, "Failed to run #{args.join(" ")} (#{st}):\n #{out}" if st.signaled? || !st.exitstatus.zero?

out
end
Expand Down
6 changes: 3 additions & 3 deletions lib/tebako/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def hash
DESC

RGP_DESCRIPTION = <<~DESC
Removes GLIBC_PRIVATE requirement from tebako package. This makes sense and works on Linux Gnu platform only and
#{" " * 65}# allows to run tebako package on the systems with different Gnu library versions.
#{" " * 65}# This feature is experimantal.
Removes GLIBC_PRIVATE reference from tebako package. This option allows to run linux-gnu tebako package against the other
#{" " * 65}# Gnu library (glibc) version that was used for packaging.
#{" " * 65}# This feature is experimantal and is supported for gnu toolchain only (not for llvm/clang).
DESC

desc "press", "Press tebako image"
Expand Down
111 changes: 71 additions & 40 deletions spec/cli_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -347,61 +347,92 @@
expect(press_announce).to eq(expected_announce)
end
end
describe "#press_options" do
context 'when options["cwd"] is set' do
let(:options) do
{ "cwd" => "/some/path", "entry-point" => "main.rb", "log-level" => "info", "root" => "test_root" }
end

it "returns the correct options string" do
expected_options = "-DROOT:STRING='#{root}' -DENTRANCE:STRING='#{options["entry-point"]}' " \
"-DPCKG:STRING='#{package}' -DLOG_LEVEL:STRING='#{options["log-level"]}' " \
"-DPACKAGE_NEEDS_CWD:BOOL=ON -DPACKAGE_CWD:STRING='#{options["cwd"]}'"
expect(press_options).to eq(expected_options)
end
end
describe "#press_options" do
context 'when options["cwd"] is set' do
let(:options) do
{ "cwd" => "/some/path", "entry-point" => "main.rb", "log-level" => "info", "root" => "test_root" }
end

context 'when options["cwd"] is not set' do
let(:options) { { "entry-point" => "main.rb", "log-level" => "info", "root" => "test_root" } }

it "returns the correct options string with default cwd option" do
expected_options = "-DROOT:STRING='#{root}' -DENTRANCE:STRING='#{options["entry-point"]}' " \
"-DPCKG:STRING='#{package}' -DLOG_LEVEL:STRING='#{options["log-level"]}' " \
"-DPACKAGE_NEEDS_CWD:BOOL=OFF"
expect(press_options).to eq(expected_options)
end
it "returns the correct options string" do
expected_options = "-DROOT:STRING='#{root}' -DENTRANCE:STRING='#{options["entry-point"]}' " \
"-DPCKG:STRING='#{package}' -DLOG_LEVEL:STRING='#{options["log-level"]}' " \
"-DPACKAGE_NEEDS_CWD:BOOL=ON -DPACKAGE_CWD:STRING='#{options["cwd"]}'"
expect(press_options).to eq(expected_options)
end
end
describe "#relative?" do
it "returns true for a relative path" do
expect(relative?("relative/path")).to be true
end

it "returns false for an absolute path" do
expect(relative?("/absolute/path")).to be false
context 'when options["cwd"] is not set' do
let(:options) { { "entry-point" => "main.rb", "log-level" => "info", "root" => "test_root" } }

it "returns the correct options string with default cwd option" do
expected_options = "-DROOT:STRING='#{root}' -DENTRANCE:STRING='#{options["entry-point"]}' " \
"-DPCKG:STRING='#{package}' -DLOG_LEVEL:STRING='#{options["log-level"]}' " \
"-DPACKAGE_NEEDS_CWD:BOOL=OFF"
expect(press_options).to eq(expected_options)
end
end
end
describe "#relative?" do
it "returns true for a relative path" do
expect(relative?("relative/path")).to be true
end

describe "#root" do
context 'when options["root"] is a relative path' do
let(:options) { { "root" => "relative/path" } }
it "returns false for an absolute path" do
expect(relative?("/absolute/path")).to be false
end
end

describe "#root" do
context 'when options["root"] is a relative path' do
let(:options) { { "root" => "relative/path" } }

it "returns the correct root path" do
expected_root = File.join(fs_current, options["root"])
expect(root).to eq(expected_root)
end
it "returns the correct root path" do
expected_root = File.join(fs_current, options["root"])
expect(root).to eq(expected_root)
end
end

context 'when options["root"] is an absolute path' do
let(:options) { { "root" => "/absolute/path" } }
context 'when options["root"] is an absolute path' do
let(:options) { { "root" => "/absolute/path" } }

it "returns the correct root path" do
expected_root = File.join(options["root"], "")
expect(root).to eq(expected_root)
end
it "returns the correct root path" do
expected_root = File.join(options["root"], "")
expect(root).to eq(expected_root)
end
end
end

describe "#version_unknown" do
it "calls clean_cache and outputs the correct message" do
expect(self).to receive(:clean_cache)
expect { version_unknown }.to output("CMake cache version was not recognized, cleaning up\n").to_stdout
end
end

describe "#version_mismatch" do
it "calls clean_cache and outputs the correct message" do
cached_v = "1.0.0"
expect(self).to receive(:clean_cache)
expect do
version_mismatch(cached_v)
end.to output(
"Tebako cache was created by a gem version #{cached_v} and cannot be used for gem version #{Tebako::VERSION}\n"
).to_stdout
end
end

describe "#version_source_mismatch" do
it "handles version source mismatch scenario" do
cached_s = "/old/source"
expect(self).to receive(:clean_output)
expect do
version_source_mismatch(cached_s)
end.to output(
"CMake cache was created for a different source directory '#{cached_s}' and cannot be used for '#{source}'\n"
).to_stdout
end
end
end

# rubocop:enable Metrics/BlockLength

0 comments on commit 0d5ad7a

Please sign in to comment.