Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/cps/pc_compat/pc_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,11 @@ namespace cps::pc_compat {
return loader::Package{.name = name,
.cps_version = std::string{loader::CPS_VERSION},
.components = components,
// TODO: consider how pkg-config actually handles version and
.compat_version = version,
// TODO: treat PREFIX in pc file specially and translate it to @prefix@
.cps_path = std::nullopt,
.prefix = fs::path{""},
.filename = filename.string(),
.default_components = std::vector{name},
.platform = std::nullopt,
Expand Down
2 changes: 2 additions & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ foreach t : ['loader', 'version', 'utils', 'pc_parser']
protocol : 'gtest',
)
endforeach

subdir('pkgconf')
6 changes: 6 additions & 0 deletions tests/pkgconf/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# We need these mostly unset because we're testing weird whitespaces and formats
[*.pc]
end_of_line = unset
indent_style = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
41 changes: 41 additions & 0 deletions tests/pkgconf/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
A. Wilcox <AWilcox@Wilcox-Tech.com>
Alexander Tsoy <alexander@tsoy.me>
Alexpux <alexey.pawlow@gmail.com>
Alon Bar-Lev <alon.barlev@gmail.com>
Alyx <alyx@malkier.net>
Ariadne Conill <ariadne@dereferenced.org>
Baptiste Daroussin <bapt@FreeBSD.org>
Baptiste Daroussin <bapt@gandi.net>
Bryan Drewery <bryan@shatow.net>
Dag-Erling Smørgrav <des@des.no>
Dan Kegel <dank@kegel.com>
Dan Kegel <dank@oblong.com>
Dan Nicholson <dbn.lists@gmail.com>
David Michael <fedora.dm0@gmail.com>
Emil Renner Berthing <esmil@mailme.dk>
Fabian Groffen <grobian@gentoo.org>
Graham Ollis <plicease@cpan.org>
Gregor Richards <Richards@codu.org>
Ignacio Casal Quinteiro <qignacio@amazon.com>
Igor Gnatenko <ignatenko@redhat.com>
Issam Maghni <concatime@users.noreply.github.com>
JD Horelick <jdhore1@gmail.com>
Jason Dusek <jason.dusek@gmail.com>
Javier Viguera <javier.viguera@digi.com>
Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
John Hein <jhgit@users.github.com>
Jussi Pakkanen <jpakkane@gmail.com>
Leorize <alaviss@users.noreply.github.com>
Luca Barbato <lu_zero@gentoo.org>
Marcin Wojdyr <wojdyr@gmail.com>
Maxin B. John <maxinbjohn@users.noreply.github.com>
Michał Górny <mgorny@gentoo.org>
Mike Frysinger <vapier@gentoo.org>
Seungha Yang <seungha.yang@navercorp.com>
TingPing <tingping@tingping.se>
Tobias Kortkamp <t6@users.noreply.github.com>
Tony Theodore <tonyt@logyst.com>
Volker Braun <vbraun.name@gmail.com>
Yu Kobayashi <yukoba@accelart.jp>
orbea <orbea@fredslev.dk>
✈ Graham ✈ <plicease@cpan.org>
10 changes: 10 additions & 0 deletions tests/pkgconf/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
pkgconf authors (see AUTHORS file in source directory).

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

This software is provided 'as is' and without any warranty, express or
implied. In no event shall the authors be liable for any damages arising
from the use of this software.
219 changes: 219 additions & 0 deletions tests/pkgconf/basic.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
[setup]
[setup.env]
PKG_CONFIG_PATH="{test_root}/lib1"

[noargs]
exitcode = 1
stderr = '<ignore>'
expected_fail = true

[libs]
stdout = "-L/test/lib -lfoo\n"
args = ["--libs", "foo"]
expected_fail = true

[lib_cflags]
stdout = "-fPIC -I/test/include/foo -L/test/lib -lfoo\n"
args = ["--cflags", "--libs", "foo"]
expected_fail = true

[lib_cflags_version]
stdout = "-fPIC -I/test/include/foo -L/test/lib -lfoo\n"
args = ["--cflags", "--libs", "foo > 1.2"]
expected_fail = true

[lib_cflags_version_multiple]
stdout = "-fPIC -I/test/include/foo -L/test/lib -lbar -lfoo\n"
args = ["--cflags", "--libs", "foo > 1.2 bar >= 1.3"]
expected_fail = true

[lib_cflags_version_multiple_comma]
stdout = "-fPIC -I/test/include/foo -L/test/lib -lbar -lfoo\n"
args = ["--cflags", "--libs", "foo > 1.2,bar >= 1.3"]
expected_fail = true

[lib_cflags_version_alt]
stdout = "-fPIC -I/test/include/foo -L/test/lib -lfoo\n"
args = ["--cflags", "--libs", "foo", ">", "1.2"]
expected_fail = true

[lib_cflags_version_different]
stdout = "-fPIC -I/test/include/foo -L/test/lib -lfoo\n"
args = ["--cflags", "--libs", "foo", "!=", "1.3"]
expected_fail = true

[lib_cflags_version_different_bad]
exitcode = 1
stderr = "Package dependency requirement 'foo != 1.2.3' could not be satisfied.\nPackage 'foo' has version '1.2.3', required version is '!= 1.2.3'\n"
args = ["--cflags", "--libs", "foo", "!=", "1.2.3"]
expected_fail = true

[exists_nonexistent]
exitcode = 1
args = ["--exists", "nonexistant"]
expected_fail = true

[nonexistent]
exitcode = 1
args = ["nonexistant"]

[exists_version]
args = ["--exists", "foo > 1.2"]
expected_fail = true

[exists_version_alt]
args = ["--exists", "foo", ">", "1.2"]
expected_fail = true

[exists_version_bad]
exitcode = 1
args = ["--exists", "foo > 1.2.3"]
expected_fail = true

[uninstalled_bad]
exitcode = 1
args = ["--uninstalled", "foo"]
expected_fail = true

[uninstalled]
args = ["--uninstalled", "omg"]
expected_fail = true

[exists_version_bad2]
exitcode = 1
args = ["--exists", "foo >= "]
expected_fail = true

[exists_version_bad3]
exitcode = 1
args = ["--exists", "tilde >= 1.0.0"]
expected_fail = true

[exists]
args = ["--exists", "tilde >= 1.0.0"]
expected_fail = true

[exists2]
args = ["--exists", "tilde >= 1.0.0~rc1"]
expected_fail = true

[exists3]
args = ["--exists", "", "foo"]
expected_fail = true

[intermediary]
args = ["--libs", "intermediary-1", "intermediary-2"]
stdout = "-lintermediary-1 -lintermediary-2 -lfoo -lbar -lbaz\n"
expected_fail = true

[circular2]
args = ["circular-2", "--validate"]
stdout = "circular-1: breaking circular reference (circular-1 -> circular-2 -> circular-1)\n"
expected_fail = true

[circular1]
args = ["circular-1", "--validate"]
stdout = "circular-3: breaking circular reference (circular-3 -> circular-1 -> circular-3)\n"
expected_fail = true

[circular_direct_pc]
args = ["--libs", "{test_root}/lib1/circular-3.pc"]
stdout = "-lcircular-3 -lcircular-1 -lcircular-2\n"
expected_fail = true

[libs_static]
args = ["--libs", "static-archive-libs"]
stdout = "/libfoo.a -pthread\n"
expected_fail = true

[pkg_config_path]
args = ["--libs", "foo"]
stdout = "-L/test/lib -lfoo\n"
expected_fail = true

[pkg_config_path.env]
PKG_CONFIG_PATH = "{test_root}/lib1:{test_root}/lib2"

[pkg_config_path2]
args = ["--libs", "bar"]
stdout = "-L/test/lib -lbar -lfoo\n"
expected_fail = true

[pkg_config_path2.env]
PKG_CONFIG_PATH = "{test_root}/lib1:{test_root}/lib2"

[with_path]
args = ["--with-path={test_root}/lib", "--with-path={test_root}/lib2", "--libs", "foo"]
stdout = "-L/test/lib -lfoo\n"
expected_fail = true

[with_path2]
args = ["--with-path={test_root}/lib", "--with-path={test_root}/lib2", "--libs", "bar"]
stdout = "-L/test/lib -lbar -lfoo\n"
expected_fail = true

[nolibs]
args = ["--libs", "nolib"]
stdout = "\n"
expected_fail = true

[nocflags]
args = ["--cflags", "nocflag"]
stdout = "\n"

# TODO: [arbitrary_path]

# TODO: This doesn't work, needs some more magic?
#[relocatable_body]
# args = ["--define-prefix", "--variable=prefix", "tests/lib-relocatable/lib/pkgconfig/foo.pc"]
# stdout = "tests/lib-relocatable\n"

[single_depth_selectors]
args = ["--with-path={test_root}/lib3", "--print-requires", "bar"]
stdout = "foo\n"
expected_fail = true

[single_depth_selectors.env]
PKG_CONFIG_MAXIMUM_TRAVERSAL_DEPTH = "1"

[license_isc]
args = ["--license", "foo"]
stdout = "foo: ISC\n"
expected_fail = true

[license_noassertion]
args = ["--license", "bar"]
stdout = "bar: NOASSERTION\nfoo: ISC\n"
expected_fail = true

[modversion_noflatten]
args = ["--modversion", "bar"]
stdout = "1.3\n"
expected_fail = true

[exists_cflags]
args = ["--with-path={test_root}/lib", "--cflags", "--exists-cflags", "--fragment-filter=D", "foo"]
stdout = "-DHAVE_FOO\n"
expected_fail = true

[exists_cflags_env]
args = ["--with-path={test_root}/lib", "--cflags", "--exists-cflags", "--fragment-filter=D", "--env=FOO", "foo"]
stdout = "FOO_CFLAGS='-DHAVE_FOO'\n"
expected_fail = true

[libs_env]
args = ["--with-path={test_root}/lib", "--libs", "--env=FOO", "foo"]
stdout = "FOO_LIBS='-L/test/lib -lfoo'\n"
expected_fail = true

[print_variables_env]
args = ["--with-path={test_root}/lib", "--env=FOO", "--print-variables", "--cflags", "--libs", "foo"]
stdout = "FOO_CFLAGS='-fPIC -I/test/include/foo'\nFOO_LIBS='-L/test/lib -lfoo'\nFOO_INCLUDEDIR='/test/include'\nFOO_LIBDIR='/test/lib'\nFOO_EXEC_PREFIX='/test'\nFOO_PREFIX='/test'\nFOO_PCFILEDIR='{test_root}/lib1'\n"
expected_fail = true

[variable_env]
args = ["--with-path={test_root}/lib", "--env=FOO", "--variable=includedir", "foo"]
stdout = "FOO_INCLUDEDIR='/test/include'\n"
expected_fail = true

# TODO: variable_env
23 changes: 23 additions & 0 deletions tests/pkgconf/builtins.toml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[setup]
[setup.env]
PKG_CONFIG_PATH="{test_root}/lib1"

[modversion]
args = ["--modversion", "pkg-config"]
stdout = "@PKGCONF_VERSION@\n"
expected_fail = true

[variable]
args = ["--variable=prefix", "foo"]
stdout = "/test\n"
expected_fail = true

[define_variable]
args = ["--define-variable=prefix=/test2", "--variable=prefix", "foo"]
stdout = "/test2\n"
expected_fail = true

# TODO: global_variable
# TODO: argv_parser_3
# TODO: tilde_quoting
# TODO: paren_quoting
13 changes: 13 additions & 0 deletions tests/pkgconf/conflicts.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[setup]
[setup.env]
PKG_CONFIG_PATH="{test_root}/lib1"

[libs]
args = ["--libs", "conflicts"]
stdout = "-L/test/lib -lconflicts\n"
expected_fail = true

[ignore]
args = ["--ignore-conflicts", "--libs", "conflicts"]
stdout = "-L/test/lib -lconflicts\n"
expected_fail = true
18 changes: 18 additions & 0 deletions tests/pkgconf/framework.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[setup]
[setup.env]
PKG_CONFIG_PATH="{test_root}/lib1"

[libs1]
args = ["--libs", "framework-1"]
stdout = "-F/test/lib -framework framework-1\n"
expected_fail = true

[libs2]
args = ["--libs", "framework-2"]
stdout = "-F/test/lib -framework framework-2 -framework framework-1\n"
expected_fail = true

[libs3]
args = ["--libs", "framework-1", "framework-2"]
stdout = "-F/test/lib -framework framework-2 -framework framework-1\n"
expected_fail = true
11 changes: 11 additions & 0 deletions tests/pkgconf/lib-relocatable/lib/pkgconfig/foo.pc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=/test
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

Name: foo
Description: A testing pkg-config file
Version: 1.2.3
Libs: -L${libdir} -lfoo
Cflags: -fPIC -I${includedir}/foo
Cflags.private: -DFOO_STATIC
10 changes: 10 additions & 0 deletions tests/pkgconf/lib1/argv-parse-2.pc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
prefix=/test
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

Name: argv-parse-2
Description: A testing pkg-config file
Version: 1.2.3
Libs: -llib-1 -pthread ${libdir}/lib2.so
Cflags:
11 changes: 11 additions & 0 deletions tests/pkgconf/lib1/argv-parse-3.pc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=/test
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include

Name: argv-parse-3
Description: A testing pkg-config file
Version: 1.2.3
Libs: -llib-1 \
-pthread ${libdir}/lib2.so
Cflags:
Loading