[rubygems/rubygems] Use a constant empty tar header to avoid extra allocations
[ruby.git] / test / test_extlibs.rb
blob9b6676416cfc9d9daafb6cd1a497f8691559f6bc
1 # frozen_string_literal: false
2 require "envutil"
3 require "shellwords"
5 class TestExtLibs < Test::Unit::TestCase
6   @extdir = $".grep(/\/rbconfig\.rb\z/) {break "#$`/ext"}
8   def self.check_existence(ext, add_msg = nil)
9     return if @excluded.any? {|i| File.fnmatch?(i, ext, File::FNM_CASEFOLD)}
10     add_msg = ".  #{add_msg}" if add_msg
11     log = "#{@extdir}/#{ext}/mkmf.log"
12     define_method("test_existence_of_#{ext}") do
13       assert_separately([], <<-"end;", ignore_stderr: true) # do
14         log = #{log.dump}
15         msg = proc {
16           "extension library `#{ext}' is not found#{add_msg}\n" <<
17             (File.exist?(log) ? File.binread(log) : "\#{log} not found")
18         }
19         assert_nothing_raised(msg) do
20           require "#{ext}"
21         end
22       end;
23     end
24   end
26   def windows?
27     /mswin|mingw/ =~ RUBY_PLATFORM
28   end
30   excluded = [RbConfig::CONFIG, ENV].map do |conf|
31     if args = conf['configure_args']
32       args.shellsplit.grep(/\A--without-ext=/) {$'.split(/,/)}
33     end
34   end.flatten.compact
35   excluded << '+' if excluded.empty?
36   if windows?
37     excluded.map! {|i| i == '+' ? ['pty'] : i}
38     excluded.flatten!
39   else
40     excluded.map! {|i| i == '+' ? '*win32*' : i}
41   end
42   @excluded = excluded
44   check_existence "continuation"
45   check_existence "coverage"
46   check_existence "date"
47   check_existence "digest"
48   check_existence "digest/bubblebabble"
49   check_existence "digest/md5"
50   check_existence "digest/rmd160"
51   check_existence "digest/sha1"
52   check_existence "digest/sha2"
53   check_existence "etc"
54   check_existence "fcntl"
55   check_existence "fiber"
56   check_existence "fiddle"
57   check_existence "io/console"
58   check_existence "io/nonblock"
59   check_existence "io/wait"
60   check_existence "json"
61   check_existence "objspace"
62   check_existence "openssl", "this may be false positive, but should assert because rubygems requires this"
63   check_existence "pathname"
64   check_existence "psych"
65   check_existence "pty"
66   check_existence "rbconfig/sizeof"
67   check_existence "ripper"
68   check_existence "socket"
69   check_existence "stringio"
70   check_existence "strscan"
71   check_existence "thread"
72   check_existence "win32ole"
73   check_existence "zlib", "this may be false positive, but should assert because rubygems requires this"
74 end