[M6] manifest: add dev_dependencies and [build].include_dirs
This commit is contained in:
@@ -206,9 +206,8 @@ TEST_CASE("cmake_lists emits find_package per dep", "[codegen][cmake]") {
|
||||
|
||||
TEST_CASE("cmake_lists honors warnings_as_errors", "[codegen][cmake]") {
|
||||
Manifest m{
|
||||
pkg("app"),
|
||||
{},
|
||||
BuildSettings{.warnings_as_errors = true, .sanitizers = {}},
|
||||
.package = pkg("app"),
|
||||
.build = BuildSettings{.warnings_as_errors = true, .sanitizers = {}},
|
||||
};
|
||||
DiscoveredLayout layout{
|
||||
.library = std::nullopt,
|
||||
@@ -226,10 +225,9 @@ TEST_CASE("cmake_lists honors warnings_as_errors", "[codegen][cmake]") {
|
||||
|
||||
TEST_CASE("cmake_lists honors sanitizers", "[codegen][cmake]") {
|
||||
Manifest m{
|
||||
pkg("app"),
|
||||
{},
|
||||
BuildSettings{.warnings_as_errors = false,
|
||||
.sanitizers = {"address", "undefined"}},
|
||||
.package = pkg("app"),
|
||||
.build = BuildSettings{.warnings_as_errors = false,
|
||||
.sanitizers = {"address", "undefined"}},
|
||||
};
|
||||
DiscoveredLayout layout{
|
||||
.library = std::nullopt,
|
||||
|
||||
@@ -199,9 +199,6 @@ TEST_CASE("parse accepts reserved top-level tables", "[manifest][parse]") {
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
gtest = "1.14"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
||||
@@ -212,6 +209,63 @@ members = ["a"]
|
||||
REQUIRE(r.has_value());
|
||||
}
|
||||
|
||||
TEST_CASE("parse extracts dev-dependencies", "[manifest][parse]") {
|
||||
auto p = write_manifest(R"(
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
|
||||
[dev-dependencies]
|
||||
catch2 = "3.5.0"
|
||||
gtest = { version = "1.14", components = ["gmock"] }
|
||||
)");
|
||||
auto r = parse(p);
|
||||
REQUIRE(r.has_value());
|
||||
REQUIRE(r->dev_dependencies.size() == 2);
|
||||
auto find = [&](std::string_view n) {
|
||||
return std::ranges::find_if(r->dev_dependencies,
|
||||
[&](const auto& d) { return d.name == n; });
|
||||
};
|
||||
auto catch2 = find("catch2");
|
||||
REQUIRE(catch2 != r->dev_dependencies.end());
|
||||
REQUIRE(catch2->version_spec == "3.5.0");
|
||||
REQUIRE(catch2->components.empty());
|
||||
auto gtest = find("gtest");
|
||||
REQUIRE(gtest != r->dev_dependencies.end());
|
||||
REQUIRE(gtest->version_spec == "1.14");
|
||||
REQUIRE(gtest->components == std::vector<std::string>{"gmock"});
|
||||
}
|
||||
|
||||
TEST_CASE("parse extracts [build].include_dirs", "[manifest][parse]") {
|
||||
auto p = write_manifest(R"(
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
|
||||
[build]
|
||||
include_dirs = ["third_party", "vendor/spdlog"]
|
||||
)");
|
||||
auto r = parse(p);
|
||||
REQUIRE(r.has_value());
|
||||
REQUIRE(r->build.include_dirs ==
|
||||
std::vector<std::string>{"third_party", "vendor/spdlog"});
|
||||
}
|
||||
|
||||
TEST_CASE("parse rejects [build].include_dirs that escape the project",
|
||||
"[manifest][parse]") {
|
||||
auto p = write_manifest(R"(
|
||||
[package]
|
||||
name = "foo"
|
||||
version = "0.1.0"
|
||||
|
||||
[build]
|
||||
include_dirs = ["../escape"]
|
||||
)");
|
||||
auto r = parse(p);
|
||||
REQUIRE_FALSE(r.has_value());
|
||||
REQUIRE(r.error().code == cargoxx::util::ErrorCode::ManifestInvalidField);
|
||||
}
|
||||
|
||||
TEST_CASE("parse rejects invalid name with spaces", "[manifest][parse]") {
|
||||
auto p = write_manifest(R"(
|
||||
[package]
|
||||
|
||||
@@ -93,10 +93,18 @@ TEST_CASE("write sorts dependencies alphabetically (matches Cargo)",
|
||||
|
||||
TEST_CASE("write round-trips build settings", "[manifest][write]") {
|
||||
Manifest m{
|
||||
pkg("foo", "0.1.0"),
|
||||
{},
|
||||
BuildSettings{.warnings_as_errors = true,
|
||||
.sanitizers = {"address", "undefined"}},
|
||||
.package = pkg("foo", "0.1.0"),
|
||||
.build = BuildSettings{.warnings_as_errors = true,
|
||||
.sanitizers = {"address", "undefined"},
|
||||
.include_dirs = {"third_party"}},
|
||||
};
|
||||
REQUIRE(round_trip(m) == m);
|
||||
}
|
||||
|
||||
TEST_CASE("write round-trips dev-dependencies", "[manifest][write]") {
|
||||
Manifest m{
|
||||
.package = pkg("foo", "0.1.0"),
|
||||
.dev_dependencies = {Dependency{.name = "catch2", .version_spec = "3.5.0"}},
|
||||
};
|
||||
REQUIRE(round_trip(m) == m);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user