diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-04-22 13:01:43 -0700 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2022-04-22 15:00:16 -0700 |
commit | ab3cb29bd9bff9c16cfb9d19cc02026998282c12 (patch) | |
tree | 6127856f758af8ff4b435f845c2777e0f478ca94 /test/mkmf/test_pkg_config.rb | |
parent | c2d38a0d2d78f749fba47073b33106fd2e57767a (diff) | |
download | ruby-ab3cb29bd9bff9c16cfb9d19cc02026998282c12.tar.gz |
Avoid defining the same test class in multiple files
Should fix issues with parallel testing sometimes not running all
tests.
This should be viewed skipping whitespace changes.
Fixes [Bug #18731]
Diffstat (limited to 'test/mkmf/test_pkg_config.rb')
-rw-r--r-- | test/mkmf/test_pkg_config.rb | 98 |
1 files changed, 48 insertions, 50 deletions
diff --git a/test/mkmf/test_pkg_config.rb b/test/mkmf/test_pkg_config.rb index 1f4f48db12..72efb4ba81 100644 --- a/test/mkmf/test_pkg_config.rb +++ b/test/mkmf/test_pkg_config.rb @@ -2,67 +2,65 @@ require_relative 'base' require 'shellwords' -class TestMkmf - class TestPkgConfig < TestMkmf - PKG_CONFIG = find_executable0("pkg-config") +class TestMkmfPkgConfig < TestMkmf + PKG_CONFIG = find_executable0("pkg-config") - def setup - super + def setup + super - if PKG_CONFIG - @fixtures_dir = File.join(Dir.pwd, "fixtures") - @fixtures_lib_dir = File.join(@fixtures_dir, "lib") - @fixtures_inc_dir = File.join(@fixtures_dir, "include") + if PKG_CONFIG + @fixtures_dir = File.join(Dir.pwd, "fixtures") + @fixtures_lib_dir = File.join(@fixtures_dir, "lib") + @fixtures_inc_dir = File.join(@fixtures_dir, "include") - FileUtils.mkdir(@fixtures_dir) - File.write("fixtures/test1.pc", <<~EOF) - libdir=#{@fixtures_lib_dir} - includedir=#{@fixtures_inc_dir} + FileUtils.mkdir(@fixtures_dir) + File.write("fixtures/test1.pc", <<~EOF) + libdir=#{@fixtures_lib_dir} + includedir=#{@fixtures_inc_dir} - Name: test1 - Description: Test for mkmf pkg-config method - Version: 1.2.3 - Libs: -L${libdir} -ltest1-public - Libs.private: -ltest1-private - Cflags: -I${includedir}/cflags-I --cflags-other - EOF + Name: test1 + Description: Test for mkmf pkg-config method + Version: 1.2.3 + Libs: -L${libdir} -ltest1-public + Libs.private: -ltest1-private + Cflags: -I${includedir}/cflags-I --cflags-other + EOF - @pkg_config_path, ENV["PKG_CONFIG_PATH"] = ENV["PKG_CONFIG_PATH"], File.join(Dir.pwd, "fixtures") - end + @pkg_config_path, ENV["PKG_CONFIG_PATH"] = ENV["PKG_CONFIG_PATH"], File.join(Dir.pwd, "fixtures") end + end - def teardown - if PKG_CONFIG - ENV["PKG_CONFIG_PATH"] = @pkg_config_path - end - - super + def teardown + if PKG_CONFIG + ENV["PKG_CONFIG_PATH"] = @pkg_config_path end - def test_pkgconfig_with_option_returns_nil_on_error - pend("skipping because pkg-config is not installed") unless PKG_CONFIG - assert_nil(pkg_config("package-does-not-exist", "exists"), MKMFLOG) - end + super + end - 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) - end + def test_pkgconfig_with_option_returns_nil_on_error + pend("skipping because pkg-config is not installed") unless PKG_CONFIG + assert_nil(pkg_config("package-does-not-exist", "exists"), 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) - end + 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) + 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) - 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) + 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) end end |