Skip to content

Commit

Permalink
pkgconfig: fix default path/suffix autodetection regexp for recent pk…
Browse files Browse the repository at this point in the history
…g-config
  • Loading branch information
doudou committed Jun 9, 2016
1 parent bb7de3b commit 8e0a88b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/utilrb/pkgconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ def self.each_package(regex = nil)
end


FOUND_PATH_RX = /Scanning directory '(.*\/)((?:lib|lib64|share)\/.*)'$/
NONEXISTENT_PATH_RX = /Cannot open directory '.*\/((?:lib|lib64|share)\/.*)' in package search path:.*/
FOUND_PATH_RX = /Scanning directory (?:#\d+ )?'(.*\/)((?:lib|lib64|share)\/.*)'$/
NONEXISTENT_PATH_RX = /Cannot open directory (?:#\d+ )?'.*\/((?:lib|lib64|share)\/.*)' in package search path:.*/

# Returns the system-wide search path that is embedded in pkg-config
def self.default_search_path
Expand Down
14 changes: 14 additions & 0 deletions test/test_pkgconfig.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ def test_find_package
PkgConfig.new('test_pkgconfig')
end

def test_path_autodetection_regexp
# PkgConfig 0.26
assert("Scanning directory '/usr/share/pkgconfig'" =~ Utilrb::PkgConfig::FOUND_PATH_RX)
assert_equal '/usr/share/pkgconfig', "#{$1}#{$2}"
assert("Cannot open directory '/usr/share/pkgconfig' in package search path:" =~ Utilrb::PkgConfig::NONEXISTENT_PATH_RX)
assert_equal 'share/pkgconfig', $1

# PkgConfig 0.29.1
assert("Scanning directory #10 '/usr/share/pkgconfig'" =~ Utilrb::PkgConfig::FOUND_PATH_RX)
assert_equal '/usr/share/pkgconfig', "#{$1}#{$2}"
assert("Cannot open directory #10 '/usr/share/pkgconfig' in package search path:" =~ Utilrb::PkgConfig::NONEXISTENT_PATH_RX)
assert_equal 'share/pkgconfig', $1
end

def test_load
pkg = PkgConfig.new('test_pkgconfig')
assert_equal('test_pkgconfig', pkg.name)
Expand Down

0 comments on commit 8e0a88b

Please sign in to comment.