diff options
Diffstat (limited to 'test/mkmf')
| -rw-r--r-- | test/mkmf/test_egrep_cpp.rb | 14 | ||||
| -rw-r--r-- | test/mkmf/test_flags.rb | 4 | ||||
| -rw-r--r-- | test/mkmf/test_pkg_config.rb | 17 |
3 files changed, 27 insertions, 8 deletions
diff --git a/test/mkmf/test_egrep_cpp.rb b/test/mkmf/test_egrep_cpp.rb index 7ac0e60010..1126324965 100644 --- a/test/mkmf/test_egrep_cpp.rb +++ b/test/mkmf/test_egrep_cpp.rb @@ -10,4 +10,18 @@ class TestMkmfEgrepCpp < TestMkmf def test_not_have_func assert_equal(false, egrep_cpp(/never match/, ""), MKMFLOG) end + + class TestMkmfEgrepCxx < self + def test_cxx_egrep_cpp + assert_equal(true, MakeMakefile["C++"].egrep_cpp(/^ok/, <<~SRC), MKMFLOG) + #ifdef __cplusplus + ok + #else + #error not C++ + #endif + SRC + rescue Errno::ENOENT + omit "C++ compiler not available: #{$!.message}" + end + end end diff --git a/test/mkmf/test_flags.rb b/test/mkmf/test_flags.rb index 6fde46adec..3d908c6bb4 100644 --- a/test/mkmf/test_flags.rb +++ b/test/mkmf/test_flags.rb @@ -33,7 +33,7 @@ class TestMkmfFlags < TestMkmf end def test_try_ldflag_invalid_opt - assert_separately([], [], <<-'end;') #do + assert_separately([], [], <<-'end;', timeout: 30) #do assert(!try_ldflags("nosuch.c"), TestMkmf::MKMFLOG) assert(have_devel?, TestMkmf::MKMFLOG) end; @@ -47,7 +47,7 @@ class TestMkmfFlags < TestMkmf end def test_try_cppflag_invalid_opt - assert_separately([], [], <<-'end;') #do + assert_separately([], [], <<-'end;', timeout: 30) #do assert(!try_cppflags("nosuch.c"), TestMkmf::MKMFLOG) assert(have_devel?, TestMkmf::MKMFLOG) end; diff --git a/test/mkmf/test_pkg_config.rb b/test/mkmf/test_pkg_config.rb index f6a960c7d9..adf5fa6e92 100644 --- a/test/mkmf/test_pkg_config.rb +++ b/test/mkmf/test_pkg_config.rb @@ -46,21 +46,26 @@ class TestMkmfPkgConfig < TestMkmf def test_pkgconfig_with_libs_option_returns_output pend("skipping because pkg-config is not installed") unless PKG_CONFIG expected = ["-L#{@fixtures_lib_dir}", "-ltest1-public"].sort - actual = pkg_config("test1", "libs").shellsplit.sort - assert_equal(expected, actual, MKMFLOG) + actual = pkg_config("test1", "libs") + assert_equal_sorted(expected, actual, MKMFLOG) end def test_pkgconfig_with_cflags_option_returns_output pend("skipping because pkg-config is not installed") unless PKG_CONFIG expected = ["--cflags-other", "-I#{@fixtures_inc_dir}/cflags-I"].sort - actual = pkg_config("test1", "cflags").shellsplit.sort - assert_equal(expected, actual, MKMFLOG) + actual = pkg_config("test1", "cflags") + assert_equal_sorted(expected, actual, MKMFLOG) end def test_pkgconfig_with_multiple_options pend("skipping because pkg-config is not installed") unless PKG_CONFIG expected = ["-L#{@fixtures_lib_dir}", "-ltest1-public", "-ltest1-private"].sort - actual = pkg_config("test1", "libs", "static").shellsplit.sort - assert_equal(expected, actual, MKMFLOG) + actual = pkg_config("test1", "libs", "static") + assert_equal_sorted(expected, actual, MKMFLOG) + end + + private def assert_equal_sorted(expected, actual, msg = nil) + actual = actual.shellsplit.sort if actual + assert_equal(expected, actual, msg) end end |
