From d5e7e88f3248c59070b6e0d1dcb1166534d02a02 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 5 Aug 2025 15:48:11 +0900 Subject: [PATCH] Show mkmf.log contents even when `pkg-config` command failed --- test/mkmf/test_pkg_config.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test/mkmf/test_pkg_config.rb b/test/mkmf/test_pkg_config.rb index f6a960c7d99052..adf5fa6e92b9f5 100644 --- a/test/mkmf/test_pkg_config.rb +++ b/test/mkmf/test_pkg_config.rb @@ -46,21 +46,26 @@ def test_pkgconfig_with_option_returns_nil_on_error 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