Sha256: 7bb9e03b9c638d6ed64d28a93e800a8060bd7497b906ee5bfb0faa78b65fa2fb

Contents?: true

Size: 1.7 KB

Versions: 72

Compression:

Stored size: 1.7 KB

Contents

#
# This file is part of ruby-ffi.
# For licensing, see LICENSE.SPECS
#

require 'rbconfig'
require 'fileutils'
require 'ffi'

RSpec.configure do |c|
  c.filter_run_excluding :broken => true
end

CPU = case RbConfig::CONFIG['host_cpu'].downcase
  when /i[3456]86/
    # Darwin always reports i686, even when running in 64bit mode
    if RbConfig::CONFIG['host_os'] =~ /darwin/ && 0xfee1deadbeef.is_a?(Fixnum)
      "x86_64"
    else
      "i386"
    end

  when /amd64|x86_64/
    "x86_64"

  when /ppc64|powerpc64/
    "powerpc64"

  when /ppc|powerpc/
    "powerpc"

  when /^arm/
    "arm"

  else
    RbConfig::CONFIG['host_cpu']
  end

OS = case RbConfig::CONFIG['host_os'].downcase
  when /linux/
    "linux"
  when /darwin/
    "darwin"
  when /freebsd/
    "freebsd"
  when /openbsd/
    "openbsd"
  when /sunos|solaris/
    "solaris"
  when /mswin|mingw/
    "win32"
  else
    RbConfig::CONFIG['host_os'].downcase
  end

def compile_library(path, lib)

  dir = File.expand_path(path, File.dirname(__FILE__))
  lib = "#{dir}/#{lib}"
  if !File.exist?(lib)
    output = nil
    FileUtils.cd(dir) do
      output = system(*%{#{system('which gmake >/dev/null') && 'gmake' || 'make'} CPU=#{CPU} OS=#{OS} }.tap{|x| puts x.inspect})
    end

    if $?.exitstatus != 0
      puts "ERROR:\n#{output}"
      raise "Unable to compile \"#{lib}\""
    end
  end

  lib
end

require "ffi"

module TestLibrary
  PATH = compile_library("fixtures", "libtest.#{FFI::Platform::LIBSUFFIX}")

  def self.force_gc
    if RUBY_PLATFORM =~ /java/
      java.lang.System.gc
    elsif defined?(RUBY_ENGINE) && RUBY_ENGINE == 'rbx'
      GC.run(true)
    else
      GC.start
    end
  end
end
module LibTest
  extend FFI::Library
  ffi_lib TestLibrary::PATH
end

Version data entries

72 entries across 70 versions & 14 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
tdiary-5.0.8 vendor/bundle/gems/tdiary-5.0.7/vendor/bundle/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
vagrant-unbundled-2.0.2.0 vendor/bundle/ruby/2.5.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
ffi-1.9.21-x86-mingw32 spec/ffi/spec_helper.rb
ffi-1.9.21-x64-mingw32 spec/ffi/spec_helper.rb
ffi-1.9.21 spec/ffi/spec_helper.rb
tdiary-5.0.7 vendor/bundle/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
comiditaULL-0.1.1 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
comidita_ull-0.1.1 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
comidita_ull-0.1.0 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
vagrant-unbundled-2.0.1.0 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
cloudsmith-api-0.21.4 vendor/bundle/ruby/2.3.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
tdiary-5.0.6 vendor/bundle/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
vagrant-unbundled-2.0.0.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
vagrant-unbundled-1.9.8.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
vagrant-unbundled-1.9.7.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
tdiary-5.0.5 vendor/bundle/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/ffi-1.9.18/spec/ffi/spec_helper.rb
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/ffi-1.9.18/spec/ffi/spec_helper.rb