1require_relative 'base'
2
3class TestMkmf
4  class TestFlags < TestMkmf
5    def test_valid_warnflags
6      val = $extmk
7      warnflags = $warnflags
8      makefile = mkmf do
9        $extmk = false
10        self.class::CONFIG['warnflags'] = %w"-Wextra
11        -Wno-unused-parameter -Wno-parentheses -Wno-long-long
12        -Wno-missing-field-initializers -Werror=pointer-arith
13        -Werror=write-strings -Werror=declaration-after-statement
14        -Werror=shorten-64-to-32
15        -Werror-implicit-function-declaration
16        ".join(' ')
17        self.class::CONFIG['GCC'] = 'yes'
18        init_mkmf(self.class::CONFIG)
19        configuration '.'
20      end
21      generated_flags = makefile.grep(/warnflags/).first[/^warnflags = (.*)$/, 1].split
22
23      assert_equal %w"
24      -Wextra -Wno-unused-parameter -Wno-parentheses
25      -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith
26      -Wwrite-strings -Wdeclaration-after-statement
27      -Wshorten-64-to-32 -Wimplicit-function-declaration
28      ", generated_flags
29
30    ensure
31      $warnflags = warnflags
32      $extmk = val
33    end
34  end
35end
36