This repository was archived by the owner on Apr 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestRunner.cs
More file actions
51 lines (42 loc) · 1.91 KB
/
TestRunner.cs
File metadata and controls
51 lines (42 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Collections.Generic;
using System.IO;
using clojure.lang;
namespace Tool
{
public static class TestRunner
{
private static readonly Var REQUIRE = RT.var("clojure.core", "require");
private static readonly Var LOAD = RT.var("clojure.core", "load");
public static void Run(string testRoot = "test", string srcRoot = "src")
{
var directories = new List<string> { srcRoot, testRoot };
foreach (var directory in directories)
{
if (Directory.Exists(directory))
{
var cljFiles = Directory.GetFiles(directory, "*.cljr", SearchOption.AllDirectories);
foreach (var file in cljFiles)
{
var loadPath = Path.GetRelativePath(Directory.GetCurrentDirectory(), file)
.Replace('\\', '/') // Convert backslashes to slashes (for Windows paths)
.Substring(0, file.Length - ".cljr".Length); // Remove the file extension.
// Convert the file path to a Clojure namespace.
var ns = loadPath
.Replace('/', '.')
.Replace("_", "-"); // Convert slashes to dots.
// Then require the namespace.
REQUIRE.invoke(Symbol.intern(ns));
// ns will start with .test -- remove it so that run-tests works.
if (ns.StartsWith("test."))
{
ns = ns.Substring("test.".Length);
// TODO system exit.
var testRunner = RT.var("clojure.test", "run-tests");
testRunner.invoke(Symbol.intern(ns));
}
}
}
}
}
}
}