Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
maxirmx committed Dec 29, 2024
1 parent 0da3f44 commit 44b65c6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions spec/pass_through_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

require "rspec"
require "tebako-runtime"

# rubocop:disable Metrics/BlockLength
Expand Down Expand Up @@ -59,5 +60,36 @@
FFI::Platform.send(:remove_const, :PASS_THROUGH) if Object.const_defined?(:PASS_THROUGH)
end
end

it "is transparent for other gems in PASS_THROUGH mode" do
if RUBY_PLATFORM =~ /msys|mingw|cygwin/
if defined?(FFI)
FFI::Platform.send(:remove_const, :OS)
FFI::Platform.send(:remove_const, :ARCH)
FFI::Platform.send(:remove_const, :LIBPREFIX)
FFI::Platform.send(:remove_const, :LIBSUFFIX)
FFI::Platform.send(:remove_const, :PASS_THROUGH)
end
ENV["TEBAKO_PASS_THROUGH"] = "1"
require "fiddle"

expect(defined?(FFI::Platform::OS)).to_not be_nil
expect(defined?(FFI::Platform::ARCH)).to_not be_nil
expect(defined?(FFI::Platform::LIBPREFIX)).to_not be_nil
expect(defined?(FFI::Platform::LIBSUFFIX)).to_not be_nil
expect(FFI::Platform::PASS_THROUGH).to eq(true)
end
end

after do
if RUBY_PLATFORM =~ /msys|mingw|cygwin/
ENV.delete("TEBAKO_PASS_THROUGH")
FFI::Platform.send(:remove_const, :OS) if Object.const_defined?(:OS)
FFI::Platform.send(:remove_const, :ARCH) if Object.const_defined?(:ARCH)
FFI::Platform.send(:remove_const, :LIBPREFIX) if Object.const_defined?(:LIBPREFIX)
FFI::Platform.send(:remove_const, :LIBSUFFIX) if Object.const_defined?(:LIBSUFFIX)
FFI::Platform.send(:remove_const, :PASS_THROUGH) if Object.const_defined?(:PASS_THROUGH)
end
end
end
# rubocop:enable Metrics/BlockLength

0 comments on commit 44b65c6

Please sign in to comment.