From 9946d1814f4af9ef67e5accd9404e0fc69290f6f Mon Sep 17 00:00:00 2001 From: JassJam <0139ne@gmail.com> Date: Mon, 23 Feb 2026 12:28:50 +0000 Subject: feat: add initial test files --- .../csharp/console_with_runtime_json/.gitignore | 7 +++++++ .../csharp/console_with_runtime_json/src/Program.cs | 17 +++++++++++++++++ .../csharp/console_with_runtime_json/src/app.csproj | 14 ++++++++++++++ .../csharp/console_with_runtime_json/src/runtime.json | 7 +++++++ .../projects/csharp/console_with_runtime_json/test.lua | 10 ++++++++++ .../projects/csharp/console_with_runtime_json/xmake.lua | 6 ++++++ 6 files changed, 61 insertions(+) create mode 100644 tests/projects/csharp/console_with_runtime_json/.gitignore create mode 100644 tests/projects/csharp/console_with_runtime_json/src/Program.cs create mode 100644 tests/projects/csharp/console_with_runtime_json/src/app.csproj create mode 100644 tests/projects/csharp/console_with_runtime_json/src/runtime.json create mode 100644 tests/projects/csharp/console_with_runtime_json/test.lua create mode 100644 tests/projects/csharp/console_with_runtime_json/xmake.lua (limited to 'tests/projects/csharp/console_with_runtime_json') diff --git a/tests/projects/csharp/console_with_runtime_json/.gitignore b/tests/projects/csharp/console_with_runtime_json/.gitignore new file mode 100644 index 000000000..53e577525 --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/.gitignore @@ -0,0 +1,7 @@ +.xmake/ +build/ +bin/ +obj/ +vsxmake*/ +.vs/ + diff --git a/tests/projects/csharp/console_with_runtime_json/src/Program.cs b/tests/projects/csharp/console_with_runtime_json/src/Program.cs new file mode 100644 index 000000000..2c9b0783b --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/src/Program.cs @@ -0,0 +1,17 @@ +using System.Text.Json; + +var runtimeFile = Path.Combine(AppContext.BaseDirectory, "runtime.json"); +if (!File.Exists(runtimeFile)) +{ + Console.WriteLine("runtime.json missing"); + return; +} + +var json = File.ReadAllText(runtimeFile); +using var doc = JsonDocument.Parse(json); +var runtime = doc.RootElement.TryGetProperty("runtime", out var value) + ? value.GetString() + : "unknown"; + +Console.WriteLine($"runtime={runtime}"); + diff --git a/tests/projects/csharp/console_with_runtime_json/src/app.csproj b/tests/projects/csharp/console_with_runtime_json/src/app.csproj new file mode 100644 index 000000000..4e754bb15 --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/src/app.csproj @@ -0,0 +1,14 @@ + + + Exe + net8.0 + enable + enable + + + + PreserveNewest + + + + diff --git a/tests/projects/csharp/console_with_runtime_json/src/runtime.json b/tests/projects/csharp/console_with_runtime_json/src/runtime.json new file mode 100644 index 000000000..15bec810d --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/src/runtime.json @@ -0,0 +1,7 @@ +{ + "runtime": "xmake", + "featureFlags": { + "sample": true + } +} + diff --git a/tests/projects/csharp/console_with_runtime_json/test.lua b/tests/projects/csharp/console_with_runtime_json/test.lua new file mode 100644 index 000000000..5ab8adc69 --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/test.lua @@ -0,0 +1,10 @@ +import("lib.detect.find_tool") + +function test_build(t) + local dotnet = find_tool("dotnet") + if dotnet then + t:build() + else + return t:skip("dotnet not found") + end +end diff --git a/tests/projects/csharp/console_with_runtime_json/xmake.lua b/tests/projects/csharp/console_with_runtime_json/xmake.lua new file mode 100644 index 000000000..8d8539b26 --- /dev/null +++ b/tests/projects/csharp/console_with_runtime_json/xmake.lua @@ -0,0 +1,6 @@ +add_rules("mode.debug", "mode.release") + +target("app") + set_kind("binary") + add_rules("csharp") + add_files("src/Program.cs", "src/app.csproj") -- cgit v1.3.1