Skip to content

Commit 8d5ec27

Browse files
committed
Fix macOS test build and LLVM CI detection
1 parent 02e9174 commit 8d5ec27

21 files changed

+75
-43
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ jobs:
9292
9393
- name: Configure xmake
9494
run: |
95-
LLVM_SDK="$HOME/.xlings/data/xpkgs/xim-x-llvm/20.1.7"
96-
test -n "$LLVM_SDK"
95+
LLVM_ROOT="$HOME/.xlings/data/xpkgs/xim-x-llvm"
96+
LLVM_SDK=$(find "$LLVM_ROOT" -mindepth 1 -maxdepth 1 -type d | sort -V | tail -1)
97+
test -d "$LLVM_SDK"
98+
"$LLVM_SDK/bin/clang++" --version
9799
xmake f -m release --toolchain=llvm --sdk="$LLVM_SDK" -y -vvD
98100
99101
- name: Build with xmake

tests/llmapi/test_anthropic_live.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import mcpplibs.llmapi;
22
import std;
33

44
#include <cassert>
5+
#include "../test_print.hpp"
56

67
using namespace mcpplibs::llmapi;
78

89
int main() {
910
auto apiKey = std::getenv("ANTHROPIC_API_KEY");
1011
if (!apiKey) {
11-
std::println("ANTHROPIC_API_KEY not set, skipping live test");
12+
println("ANTHROPIC_API_KEY not set, skipping live test");
1213
return 0;
1314
}
1415

@@ -19,26 +20,26 @@ int main() {
1920

2021
// Test 1: basic chat
2122
auto resp = client.chat("Say exactly: HELLO_TEST_OK");
22-
std::println("Response: {}", resp.text());
23+
println("Response: ", resp.text());
2324
assert(!resp.text().empty());
2425
assert(resp.usage.inputTokens > 0);
2526

2627
// Test 2: system message
2728
client.clear();
2829
client.system("Always respond with exactly one word.");
2930
auto resp2 = client.chat("What color is the sky?");
30-
std::println("System test: {}", resp2.text());
31+
println("System test: ", resp2.text());
3132

3233
// Test 3: streaming
3334
client.clear();
3435
std::string streamed;
3536
auto resp3 = client.chat_stream("Say exactly: STREAM_OK", [&](std::string_view chunk) {
3637
streamed += chunk;
37-
std::print("{}", chunk);
38+
print(chunk);
3839
});
39-
std::println("");
40+
println();
4041
assert(!streamed.empty());
4142

42-
std::println("test_anthropic_live: ALL PASSED");
43+
println("test_anthropic_live: ALL PASSED");
4344
return 0;
4445
}

tests/llmapi/test_anthropic_serialize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import mcpplibs.llmapi;
22
import std;
33

44
#include <cassert>
5+
#include "../test_print.hpp"
56

67
using namespace mcpplibs::llmapi;
78

@@ -26,6 +27,6 @@ int main() {
2627
}));
2728
assert(client.provider().name() == "anthropic");
2829

29-
std::println("test_anthropic_serialize: ALL PASSED");
30+
println("test_anthropic_serialize: ALL PASSED");
3031
return 0;
3132
}

tests/llmapi/test_client.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import mcpplibs.llmapi;
22
import std;
33

44
#include <cassert>
5+
#include "../test_print.hpp"
56

67
using namespace mcpplibs::llmapi;
78

@@ -95,6 +96,6 @@ int main() {
9596
assert(client2.conversation().size() == 2);
9697
std::filesystem::remove("/tmp/test_client_conv.json");
9798

98-
std::println("test_client: ALL PASSED");
99+
println("test_client: ALL PASSED");
99100
return 0;
100101
}

tests/llmapi/test_coro.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import mcpplibs.llmapi;
22
import std;
33

44
#include <cassert>
5+
#include "../test_print.hpp"
56

67
using namespace mcpplibs::llmapi;
78

@@ -74,6 +75,6 @@ int main() {
7475
auto asyncResp = mock.chat_async({}, {});
7576
assert(asyncResp.get().text() == "mock async");
7677

77-
std::println("test_coro: ALL PASSED");
78+
println("test_coro: ALL PASSED");
7879
return 0;
7980
}

tests/llmapi/test_embeddings.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import mcpplibs.llmapi;
22
import std;
33

44
#include <cassert>
5+
#include "../test_print.hpp"
56

67
using namespace mcpplibs::llmapi;
78

89
int main() {
910
auto apiKey = std::getenv("OPENAI_API_KEY");
1011
if (!apiKey) {
11-
std::println("OPENAI_API_KEY not set, skipping");
12+
println("OPENAI_API_KEY not set, skipping");
1213
return 0;
1314
}
1415

@@ -25,8 +26,8 @@ int main() {
2526
assert(resp.embeddings.size() == 2);
2627
assert(!resp.embeddings[0].empty());
2728
assert(resp.usage.inputTokens > 0);
28-
std::println("Embedding dim: {}", resp.embeddings[0].size());
29+
println("Embedding dim: ", resp.embeddings[0].size());
2930

30-
std::println("test_embeddings: ALL PASSED");
31+
println("test_embeddings: ALL PASSED");
3132
return 0;
3233
}

tests/llmapi/test_llmapi_integration.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import mcpplibs.llmapi;
22
import std;
33

44
#include <cassert>
5+
#include "../test_print.hpp"
56

67
using namespace mcpplibs::llmapi;
78

@@ -76,6 +77,6 @@ int main() {
7677
assert(resp.tool_calls().size() == 1);
7778
assert(resp.tool_calls()[0].name == "search");
7879

79-
std::println("test_integration: ALL PASSED");
80+
println("test_integration: ALL PASSED");
8081
return 0;
8182
}

tests/llmapi/test_openai_live.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import mcpplibs.llmapi;
22
import std;
33

44
#include <cassert>
5+
#include "../test_print.hpp"
56

67
using namespace mcpplibs::llmapi;
78

89
int main() {
910
auto apiKey = std::getenv("OPENAI_API_KEY");
1011
if (!apiKey) {
11-
std::println("OPENAI_API_KEY not set, skipping live test");
12+
println("OPENAI_API_KEY not set, skipping live test");
1213
return 0;
1314
}
1415

@@ -19,7 +20,7 @@ int main() {
1920

2021
// Test 1: basic chat
2122
auto resp = client.chat("Say exactly: HELLO_TEST_OK");
22-
std::println("Response: {}", resp.text());
23+
println("Response: ", resp.text());
2324
assert(!resp.text().empty());
2425
assert(resp.usage.totalTokens > 0);
2526
assert(resp.stopReason == StopReason::EndOfTurn);
@@ -29,16 +30,16 @@ int main() {
2930
std::string streamed;
3031
auto resp2 = client.chat_stream("Say exactly: STREAM_OK", [&](std::string_view chunk) {
3132
streamed += chunk;
32-
std::print("{}", chunk);
33+
print(chunk);
3334
});
34-
std::println("");
35+
println();
3536
assert(!streamed.empty());
3637

3738
// Test 3: conversation continuity
3839
auto resp3 = client.chat("What did I just ask you to say?");
3940
assert(!resp3.text().empty());
4041
assert(client.conversation().messages.size() == 4); // 2 user + 2 assistant
4142

42-
std::println("test_openai_live: ALL PASSED");
43+
println("test_openai_live: ALL PASSED");
4344
return 0;
4445
}

tests/llmapi/test_openai_serialize.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import mcpplibs.llmapi.nlohmann.json;
33
import std;
44

55
#include <cassert>
6+
#include "../test_print.hpp"
67

78
using namespace mcpplibs::llmapi;
89
using Json = nlohmann::json;
@@ -33,6 +34,6 @@ int main() {
3334
// Test 4: provider() access
3435
assert(client.provider().name() == "openai");
3536

36-
std::println("test_openai_serialize: ALL PASSED");
37+
println("test_openai_serialize: ALL PASSED");
3738
return 0;
3839
}

tests/llmapi/test_serialization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import mcpplibs.llmapi;
22
import std;
33

44
#include <cassert>
5+
#include "../test_print.hpp"
56

67
int main() {
78
using namespace mcpplibs::llmapi;
@@ -40,6 +41,6 @@ int main() {
4041
// Cleanup
4142
std::filesystem::remove(path);
4243

43-
std::println("test_serialization: ALL PASSED");
44+
println("test_serialization: ALL PASSED");
4445
return 0;
4546
}

0 commit comments

Comments
 (0)