* 2022-01-18 [ci skip]
[ruby-80x24.org.git] / test / mkmf / test_flags.rb
bloba3596d8e557847a4cfaf38f720a2b869335c674a
1 # frozen_string_literal: false
2 require_relative 'base'
4 class TestMkmf
5   class TestFlags < TestMkmf
6     def test_valid_warnflags
7       val = $extmk
8       warnflags = $warnflags
9       makefile = mkmf do
10         $extmk = false
11         self.class::CONFIG['warnflags'] = %w"-Wextra
12         -Wno-unused-parameter -Wno-parentheses -Wno-long-long
13         -Wno-missing-field-initializers -Werror=pointer-arith
14         -Werror=write-strings -Werror=declaration-after-statement
15         -Werror=shorten-64-to-32
16         -Werror-implicit-function-declaration
17         ".join(' ')
18         self.class::CONFIG['GCC'] = 'yes'
19         init_mkmf(self.class::CONFIG)
20         configuration '.'
21       end
22       generated_flags = makefile.grep(/warnflags/).first[/^warnflags = (.*)$/, 1].split
24       assert_equal %w"
25       -Wextra -Wno-unused-parameter -Wno-parentheses
26       -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith
27       -Wwrite-strings -Wdeclaration-after-statement
28       -Wshorten-64-to-32 -Wimplicit-function-declaration
29       ", generated_flags
31     ensure
32       $warnflags = warnflags
33       $extmk = val
34     end
36     def test_try_ldflag_invalid_opt
37       assert_separately([], <<-'end;') #do
38         assert(!try_ldflags("nosuch.c"), TestMkmf::MKMFLOG)
39         assert(have_devel?, TestMkmf::MKMFLOG)
40       end;
41     end
43     def test_try_cflag_invalid_opt
44       assert_separately([], <<-'end;', timeout: 30) #do
45         assert(!try_cflags("nosuch.c"), TestMkmf::MKMFLOG)
46         assert(have_devel?, TestMkmf::MKMFLOG)
47       end;
48     end
50     def test_try_cppflag_invalid_opt
51       assert_separately([], <<-'end;') #do
52         assert(!try_cppflags("nosuch.c"), TestMkmf::MKMFLOG)
53         assert(have_devel?, TestMkmf::MKMFLOG)
54       end;
55     end
56   end
57 end