summaryrefslogtreecommitdiff
path: root/test/mkmf
diff options
context:
space:
mode:
Diffstat (limited to 'test/mkmf')
-rw-r--r--test/mkmf/test_egrep_cpp.rb14
-rw-r--r--test/mkmf/test_pkg_config.rb17
2 files changed, 25 insertions, 6 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_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