Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Oct 31, 2024
1 parent 112ab0a commit 27d04be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 28 deletions.
35 changes: 17 additions & 18 deletions spec/compiler/interpreter/lib_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,24 @@ private def ldflags_with_backtick
end

describe Crystal::Repl::Interpreter do
context "variadic calls" do
before_all do
FileUtils.mkdir_p(SPEC_CRYSTAL_LOADER_LIB_PATH)
build_c_dynlib(compiler_datapath("interpreter", "sum.c"))
end
before_all do
FileUtils.mkdir_p(SPEC_CRYSTAL_LOADER_LIB_PATH)
build_c_dynlib(compiler_datapath("interpreter", "sum.c"))

{% if flag?(:win32) %}
ENV["PATH"] = "#{SPEC_CRYSTAL_LOADER_LIB_PATH}#{Process::PATH_DELIMITER}#{ENV["PATH"]}"
{% end %}
end

after_all do
{% if flag?(:win32) %}
ENV["PATH"] = ENV["PATH"].delete_at(0, ENV["PATH"].index!(Process::PATH_DELIMITER) + 1)
{% end %}

FileUtils.rm_rf(SPEC_CRYSTAL_LOADER_LIB_PATH)
end

context "variadic calls" do
it "promotes float" do
interpret(<<-CRYSTAL).should eq 3.5
@[Link(ldflags: #{ldflags.inspect})]
Expand Down Expand Up @@ -65,18 +77,9 @@ describe Crystal::Repl::Interpreter do
LibSum.sum_int(2, E::ONE, F::FOUR)
CRYSTAL
end

after_all do
FileUtils.rm_rf(SPEC_CRYSTAL_LOADER_LIB_PATH)
end
end

context "command expansion" do
before_all do
FileUtils.mkdir_p(SPEC_CRYSTAL_LOADER_LIB_PATH)
build_c_dynlib(compiler_datapath("interpreter", "sum.c"))
end

it "expands ldflags" do
interpret(<<-CRYSTAL).should eq 4
@[Link(ldflags: #{ldflags_with_backtick.inspect})]
Expand All @@ -87,9 +90,5 @@ describe Crystal::Repl::Interpreter do
LibSum.simple_sum_int(2, 2)
CRYSTAL
end

after_all do
FileUtils.rm_rf(SPEC_CRYSTAL_LOADER_LIB_PATH)
end
end
end
10 changes: 0 additions & 10 deletions src/compiler/crystal/loader/mingw.cr
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ class Crystal::Loader
return false unless File.file?(path)

System::LibraryArchive.imported_dlls(path).all? do |dll|
unless api_set?(dll)
# TODO: is it okay to assume `search_paths` here is equivalent to
# `dll_search_paths` in the MSVC loader?
dll_full_path = @search_paths.try &.each do |search_path|
full_path = File.join(search_path, dll)
break full_path if File.file?(full_path)
end
end
dll = dll_full_path || dll

load_dll?(dll)
end
end
Expand Down

0 comments on commit 27d04be

Please sign in to comment.