Skip to content

Commit

Permalink
fix lib_spec
Browse files Browse the repository at this point in the history
  • Loading branch information
HertzDevil committed Oct 31, 2024
1 parent 027a859 commit 8633b86
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 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
2 changes: 1 addition & 1 deletion src/compiler/crystal/interpreter/context.cr
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ class Crystal::Repl::Context
# used in `Crystal::Program#each_dll_path`
private def dll_search_paths
{% if flag?(:msvc) %}
paths = CrystalLibraryPath.paths
paths = CrystalLibraryPath.default_paths

if executable_path = Process.executable_path
paths << File.dirname(executable_path)
Expand Down

0 comments on commit 8633b86

Please sign in to comment.