Skip to content

Commit

Permalink
Update CPS spec support from 0.10 to 0.12
Browse files Browse the repository at this point in the history
This updates CPS files and tests, since we now support the 0.12 spec and
not the 0.10/0.11 spec
  • Loading branch information
dcbaker committed Sep 16, 2024
1 parent 6721466 commit d908e46
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/cps/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace cps::loader {

namespace {

constexpr static std::string_view CPS_VERSION = "0.10.0";
constexpr static std::string_view CPS_VERSION = "0.12.0";

tl::expected<KnownLanguages, std::string> to_language(std::string_view s) {
if (s == "c") {
Expand Down
2 changes: 1 addition & 1 deletion src/cps/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ namespace cps::search {
// 1. the provided version (or Compat-Version) is < the required version
// 2. This package lacks required components
if (requirements.version) {
// From the CPS spec, version 0.10.0, for package::version,
// From the CPS spec, version 0.12.0, for package::version,
// which as the same semantics as requirement::version:
//
// > If not provided, the CPS will not satisfy any request for
Expand Down
2 changes: 1 addition & 1 deletion tests/cps-files/lib/cps/cps-path-not-set.cps.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cps-path-not-set",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"version": "1.0.0",
"components": {
"default": {
Expand Down
2 changes: 1 addition & 1 deletion tests/cps-files/lib/cps/cps-path-set.cps.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cps-path-set",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"cps_path": "@prefix@/${libdir}/cps/",
"version": "1.0.0",
"components": {
Expand Down
2 changes: 1 addition & 1 deletion tests/cps-files/lib/cps/diamond.cps
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "diamond",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"requires": {
"needs-components1": {},
"needs-components2": {}
Expand Down
8 changes: 6 additions & 2 deletions tests/cps-files/lib/cps/full.cps
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "full",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"version": "1.2.1",
"compat_version": "1.0.0",
"components": {
Expand Down Expand Up @@ -32,7 +32,11 @@
"/opt/include"
]
},
"link_flags": ["-L/usr/lib/", "-lbar", "-flto"],
"link_flags": [
"-L/usr/lib/",
"-lbar",
"-flto"
],
"definitions": {
"c": {
"FOO": "1",
Expand Down
2 changes: 1 addition & 1 deletion tests/cps-files/lib/cps/minimal.cps
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minimal",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"version": "1.0.0",
"components": {
"sample0": {
Expand Down
8 changes: 6 additions & 2 deletions tests/cps-files/lib/cps/multiple-components.cps
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "multiple-components",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"requires": {
"minimal": {}
},
Expand Down Expand Up @@ -55,7 +55,11 @@
},
"link-flags": {
"type": "dylib",
"link_flags": ["-L/usr/lib/", "-lbar", "-flto"],
"link_flags": [
"-L/usr/lib/",
"-lbar",
"-flto"
],
"location": "/something/lib/libfoo.so"
},
"requires-external": {
Expand Down
2 changes: 1 addition & 1 deletion tests/cps-files/lib/cps/needs-components1.cps
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "needs-components1",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"requires": {
"multiple-components": {
"components": [
Expand Down
2 changes: 1 addition & 1 deletion tests/cps-files/lib/cps/needs-components2.cps
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "needs-components2",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"requires": {
"multiple-components": {
"components": [
Expand Down
14 changes: 10 additions & 4 deletions tests/cps-files/lib/cps/needs-version.cps
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
{
"name": "needs-components1",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"requires": {
"multiple-components": {
"components": ["sample3"],
"components": [
"sample3"
],
"version": "1.0"
}
},
"components": {
"default": {
"type": "interface",
"requires": ["multiple-components:sample3"]
"requires": [
"multiple-components:sample3"
]
}
},
"default_components": ["default"]
"default_components": [
"default"
]
}
22 changes: 11 additions & 11 deletions tests/loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace cps::utils::test {
TEST(Loader, minimal_complete_package) {
std::stringstream ss(R"({
"name": "minimal_complete_package",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"components": {
"default": {
"type": "archive",
Expand All @@ -43,7 +43,7 @@ namespace cps::utils::test {
TEST(Loader, components_must_not_be_empty) {
std::stringstream ss(R"({
"name": "components_must_not_be_empty",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"components": {}
}
)"s);
Expand All @@ -55,7 +55,7 @@ namespace cps::utils::test {
TEST(Loader, archive_missing_location) {
std::stringstream ss(R"({
"name": "archive_missing_location",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"components": {
"default": {
"type": "archive",
Expand All @@ -70,7 +70,7 @@ namespace cps::utils::test {

TEST(Loader, missing_name) {
std::stringstream ss(R"({
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"components": {
"default": {
"type": "archive",
Expand Down Expand Up @@ -101,7 +101,7 @@ namespace cps::utils::test {
TEST(Loader, missing_components) {
std::stringstream ss(R"({
"name": "missing_components",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
}
)"s);
auto const package = cps::loader::load(ss, "missing_components");
Expand All @@ -111,7 +111,7 @@ namespace cps::utils::test {
TEST(Loader, name_is_string) {
std::stringstream ss(R"({
"name": [],
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"components": {
"default": {
"type": "archive",
Expand Down Expand Up @@ -144,7 +144,7 @@ namespace cps::utils::test {
TEST(Loader, components_is_object) {
std::stringstream ss(R"({
"name": "components_is_object",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"components": [],
}
)"s);
Expand Down Expand Up @@ -201,13 +201,13 @@ namespace cps::utils::test {
)"s);
auto const package = cps::loader::load(ss, "cps_version_is_0_10_0");
ASSERT_FALSE(package.has_value())
<< "should not have parsed, root requires `cps_version` value to exactly `0.10.0`";
<< "should not have parsed, root requires `cps_version` value to exactly `0.12.0`";
}

TEST(Loader, valid_component_types) {
std::stringstream ss(R"({
"name": "valid_component_types",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"components": {
"a": {
"type": "archive",
Expand Down Expand Up @@ -242,7 +242,7 @@ namespace cps::utils::test {
TEST(Loader, valid_component_type_extension) {
std::stringstream ss(R"({
"name": "valid_component_type_extension",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"components": {
"a": {
"type": "archive",
Expand All @@ -264,7 +264,7 @@ namespace cps::utils::test {
TEST(Loader, not_recognized_type_is_valid_but_ignored_can_make_empty_component) {
std::stringstream ss(R"({
"name": "not_recognized_type_is_valid_but_ignored_can_make_empty_component",
"cps_version": "0.10.0",
"cps_version": "0.12.0",
"components": {
"a": {
"type": "not_recognized_type_is_valid_but_ignored",
Expand Down

0 comments on commit d908e46

Please sign in to comment.