Skip to content

Commit 7e35c6c

Browse files
committed
feat(tests): public module packages as workspace members (zero shell)
tinyhttps/imgui/ffmpeg/opencv consume their bare names from THIS checkout via a member-level '[indices] default = { path = "../../.." }' (mcpp >= 0.0.97). Test sources are line-for-line ports of the smoke consumers (assertions unchanged); ffmpeg/opencv/imgui members are cfg(linux)-gated to the CI-validated surface with no-op mains elsewhere. The four reseeding smoke shells are deleted. Notes: - exactly ONE [indices] entry per member: xlings fails silently with >1 project-scoped index repo (mcpp#238); root-level centralization (#224) is deferred until that lands. - the old smoke's llvm@20.1.7 pin for imgui is dropped: it predates gcc16 module support; imgui-m upstream CI builds with gcc@16.1.0 (verified locally: member passes with the workspace default toolchain).
1 parent 71e292f commit 7e35c6c

8 files changed

Lines changed: 186 additions & 2 deletions

File tree

mcpp.toml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# mcpp-index is simultaneously the package index (pkgs/) AND a mcpp workspace that
22
# tests it: a virtual workspace whose members are per-library TEST projects under
3-
# tests/examples/ — each depends on this repo's own compat.<lib> via a local
4-
# [indices] path and asserts behavior in tests/*.cpp. The whole suite runs as a
3+
# tests/examples/ — each depends on this repo's own packages via a per-member
4+
# local [indices] redirect and asserts behavior in tests/*.cpp. The whole suite runs as a
55
# single shell-free command, `mcpp test --workspace` (or `mcpp test -p <lib>`).
66
# "Eat our own dog food." See
77
# .agents/docs/2026-06-29-mcpp-native-workspace-ci-design.md and
@@ -15,15 +15,27 @@ members = [
1515
"tests/examples/core",
1616
"tests/examples/eigen",
1717
"tests/examples/ffmpeg",
18+
"tests/examples/ffmpeg-module",
1819
"tests/examples/fmtlib.fmt",
1920
"tests/examples/gui-stack",
2021
"tests/examples/imgui",
22+
"tests/examples/imgui-module",
2123
"tests/examples/imgui-window",
2224
"tests/examples/marzer.tomlplusplus",
2325
"tests/examples/nlohmann.json",
2426
"tests/examples/openblas",
2527
"tests/examples/opencv",
2628
"tests/examples/opencv5",
29+
"tests/examples/opencv-module",
2730
"tests/examples/spdlog",
2831
"tests/examples/spdlog-compiled",
32+
"tests/examples/tinyhttps",
2933
]
34+
35+
36+
# NOTE: each member declares exactly ONE `[indices] <ns> = { path = "../../.." }`
37+
# entry for the namespace it consumes (module packages use `default`, the
38+
# builtin mcpplibs namespace — mcpp >= 0.0.97). Root-level centralization of
39+
# these redirects (mcpp #224) is deliberately NOT used yet: xlings fails
40+
# silently when a project has more than one project-scoped index repo
41+
# (mcpp-community/mcpp#238); revisit once fixed.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Public `ffmpeg` C++23-module package test (bare-name consumption from the
2+
# builtin default namespace — resolved against THIS checkout via the
3+
# member-level `[indices] default` redirect, mcpp >= 0.0.97; kept per-member
4+
# and single-entry because xlings breaks with >1 project index repo, mcpp#238). Replaces the
5+
# former tests/smoke_ffmpeg_module.sh reseeding driver. The package is
6+
# linux-only (source build with 157 NASM .asm units); off-Linux the test
7+
# compiles to a no-op main().
8+
[package]
9+
name = "ffmpeg-module-tests"
10+
version = "0.1.0"
11+
12+
# The module package's own transitive dep (compat.ffmpeg) resolves from the
13+
# GLOBAL published compat index (the compat namespace is not redirected here
14+
# — see the mcpp#238 single-repo constraint); the compat descriptor itself is
15+
# pre-merge-validated by its dedicated member.
16+
[indices]
17+
default = { path = "../../.." }
18+
19+
[target.'cfg(linux)'.dependencies]
20+
ffmpeg = "0.0.1"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Public ffmpeg module package end-to-end assertion: import-only consumption
2+
// (`import ffmpeg.av;`), libavutil version of the FFmpeg 8.1.x train, core
3+
// decoders present, demuxer registry populated. Linux-only (see mcpp.toml).
4+
#ifdef __linux__
5+
import std;
6+
import ffmpeg.av;
7+
8+
int main() {
9+
unsigned v { avutil_version() };
10+
std::println("libavutil {}.{} module package ok", v >> 16, (v >> 8) & 0xff);
11+
if ((v >> 16) != 60u) { // libavutil major of the FFmpeg 8.1.x train
12+
return 1;
13+
}
14+
15+
for (auto name : { "h264", "hevc", "av1", "aac" }) {
16+
const AVCodec* dec { avcodec_find_decoder_by_name(name) };
17+
if (dec == nullptr) {
18+
std::println("decoder {} MISSING", name);
19+
return 2;
20+
}
21+
}
22+
23+
void* it { nullptr };
24+
long demuxers { 0 };
25+
while (av_demuxer_iterate(&it)) ++demuxers;
26+
std::println("{} demuxers registered", demuxers);
27+
return demuxers > 300 ? 0 : 3;
28+
}
29+
#else
30+
int main() { return 0; }
31+
#endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Public `imgui` C++23-module package test (bare-name consumption from the
2+
# builtin default namespace — resolved against THIS checkout via the
3+
# member-level `[indices] default` redirect, mcpp >= 0.0.97; kept per-member
4+
# and single-entry because xlings breaks with >1 project index repo, mcpp#238). Replaces the
5+
# former tests/smoke_imgui_module.sh reseeding driver. Linux-gated to the
6+
# validated surface: the package descriptor covers three platforms, but only
7+
# linux has ever been exercised by index CI; off-Linux the test compiles to a
8+
# no-op main(). Toolchain: workspace default (gcc@16.1.0) — the old smoke's
9+
# llvm@20.1.7 pin predates gcc16 module support; imgui-m upstream CI builds
10+
# the module layer with gcc@16.1.0.
11+
[package]
12+
name = "imgui-module-tests"
13+
version = "0.1.0"
14+
15+
[indices]
16+
default = { path = "../../.." }
17+
18+
[target.'cfg(linux)'.dependencies]
19+
imgui = "0.0.1"
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Public imgui module package end-to-end assertion: import-only consumption
2+
// (imgui.core + glfw_opengl3 backend), context + font atlas + one frame,
3+
// software-only (no window). Linux-only (see mcpp.toml).
4+
#ifdef __linux__
5+
import std;
6+
import imgui.core;
7+
import imgui.backend.glfw_opengl3;
8+
9+
int main() {
10+
auto init = &ImGui::Backend::GlfwOpenGL3::Init;
11+
auto shutdown = &ImGui::Backend::GlfwOpenGL3::Shutdown;
12+
if (init == nullptr || shutdown == nullptr) {
13+
return 1;
14+
}
15+
16+
ImGuiContext* context = ImGui::CreateContext();
17+
if (context == nullptr) {
18+
return 2;
19+
}
20+
ImGui::SetCurrentContext(context);
21+
22+
ImGuiIO& io = ImGui::GetIO();
23+
io.DisplaySize = ImVec2 { 320.0f, 240.0f };
24+
unsigned char* pixels = nullptr;
25+
int width = 0;
26+
int height = 0;
27+
io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
28+
if (pixels == nullptr || width <= 0 || height <= 0) {
29+
ImGui::DestroyContext(context);
30+
return 3;
31+
}
32+
33+
ImGui::NewFrame();
34+
bool open = true;
35+
ImGui::Begin("mcpp-index imgui smoke", &open);
36+
ImGui::TextUnformatted("import imgui.core");
37+
ImGui::End();
38+
ImGui::Render();
39+
40+
std::println("Dear ImGui {} module package ok", ImGui::GetVersion());
41+
ImGui::DestroyContext(context);
42+
return 0;
43+
}
44+
#else
45+
int main() { return 0; }
46+
#endif
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Public `opencv` C++23-module package test (bare-name consumption from the
2+
# builtin default namespace — resolved against THIS checkout via the
3+
# member-level `[indices] default` redirect, mcpp >= 0.0.97; kept per-member
4+
# and single-entry because xlings breaks with >1 project index repo, mcpp#238). Replaces the
5+
# former tests/smoke_opencv_module.sh reseeding driver. The package is
6+
# linux-only (it pulls the linux-only compat.opencv5 source build); off-Linux
7+
# the test compiles to a no-op main().
8+
[package]
9+
name = "opencv-module-tests"
10+
version = "0.1.0"
11+
12+
# The module package's own transitive dep (compat.opencv5) resolves from the
13+
# GLOBAL published compat index (the compat namespace is not redirected here
14+
# — see the mcpp#238 single-repo constraint); the compat descriptor itself is
15+
# pre-merge-validated by its dedicated member.
16+
[indices]
17+
default = { path = "../../.." }
18+
19+
[target.'cfg(linux)'.dependencies]
20+
opencv = "0.0.2"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Public opencv module package end-to-end assertion: import-only consumption
2+
// (`import opencv.cv;`), pinned version, Mat/imgproc ops (incl. the
3+
// replacement operator surface: Size comparison via != crosses the module
4+
// boundary — the v0.0.1 regression scenario), PNG+JPEG codec roundtrips,
5+
// videoio registry. Linux-only (see mcpp.toml).
6+
#ifdef __linux__
7+
import std;
8+
import opencv.cv;
9+
10+
int main() {
11+
if (cv::getVersionString() != "5.0.0") return 1;
12+
13+
cv::Mat img(64, 64, cv::CV_8UC3, cv::Scalar(30, 60, 90));
14+
cv::circle(img, {32, 32}, 20, {255, 255, 255}, -1);
15+
cv::Mat big, gray;
16+
cv::resize(img, big, {128, 128}, 0, 0, cv::INTER_CUBIC);
17+
cv::cvtColor(big, gray, cv::COLOR_BGR2GRAY);
18+
if (gray.size() != cv::Size(128, 128)) return 2;
19+
20+
for (const char* ext : { ".png", ".jpg" }) {
21+
std::vector<unsigned char> buf;
22+
if (!cv::imencode(ext, big, buf)) return 3;
23+
cv::Mat back = cv::imdecode(buf, cv::IMREAD_COLOR);
24+
if (back.empty() || back.size() != big.size()) return 4;
25+
}
26+
27+
if (cv::videoio_registry::getBackends().empty()) return 5;
28+
std::println("OpenCV {} module package ok", cv::getVersionString());
29+
return 0;
30+
}
31+
#else
32+
int main() { return 0; }
33+
#endif

tests/examples/tinyhttps/mcpp.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
name = "tinyhttps-tests"
33
version = "0.1.0"
44

5+
[indices]
6+
default = { path = "../../.." }
7+
58
[dependencies]
69
tinyhttps = "0.2.9"

0 commit comments

Comments
 (0)