From f4e2bd33c2053cc68ce4a0af512f3725f10f31ef Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 30 Jun 2025 07:33:13 -0700 Subject: [PATCH 1/2] Test the C++ generator in CI Updating CI configuration to ensure that `cpp` is listed under the languages tested. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 403e2f501..dc70ebdd6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,7 +59,7 @@ jobs: matrix: os: [ubuntu-latest, macos-latest, windows-latest] # moonbit removed from language matrix for now - causing CI failures - lang: [c, rust, csharp] + lang: [c, rust, csharp, cpp] exclude: # For now csharp doesn't work on macos, so exclude it from testing. - os: macos-latest From f6cda6aad97733b5a3c1b35777172b2305488821 Mon Sep 17 00:00:00 2001 From: Christof Petig <33882057+cpetig@users.noreply.github.com> Date: Tue, 1 Jul 2025 01:17:37 +0200 Subject: [PATCH 2/2] Fix all runtime and most codegen tests (#3) * fix runtime tests * fix the majority of codegen tests --- crates/test/src/cpp.rs | 10 ++++++++++ tests/runtime/lists/test.cpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/test/src/cpp.rs b/crates/test/src/cpp.rs index fe9db9c84..ab0ccbe20 100644 --- a/crates/test/src/cpp.rs +++ b/crates/test/src/cpp.rs @@ -177,6 +177,13 @@ impl LanguageMethods for Cpp { } fn verify(&self, runner: &crate::Runner<'_>, verify: &crate::Verify) -> anyhow::Result<()> { + // for expected + let cwd = std::env::current_dir()?; + let mut helper_dir2 = cwd; + helper_dir2.push("crates"); + helper_dir2.push("cpp"); + helper_dir2.push("test_headers"); + let compiler = clangpp(runner); let mut cmd = Command::new(compiler); cmd.arg( @@ -186,11 +193,14 @@ impl LanguageMethods for Cpp { ) .arg("-I") .arg(&verify.bindings_dir) + .arg("-I") + .arg(helper_dir2.to_str().unwrap().to_string()) .arg("-Wall") .arg("-Wextra") .arg("-Werror") .arg("-Wc++-compat") .arg("-Wno-unused-parameter") + .arg("-std=c++20") .arg("-c") .arg("-o") .arg(verify.artifacts_dir.join("tmp.o")); diff --git a/tests/runtime/lists/test.cpp b/tests/runtime/lists/test.cpp index 0324b652a..edc9c1340 100644 --- a/tests/runtime/lists/test.cpp +++ b/tests/runtime/lists/test.cpp @@ -33,7 +33,7 @@ static bool equal(std::span const&a, std::vector const& b) { } template static bool equal(wit::vector const&a, std::vector const& b) { - return equal(a.get_view(), std::span(b)); + return equal(a.get_view(), std::span(b.begin(), b.end())); } template static bool equal(std::tuple const&a, std::tuple const& b) {