-
Notifications
You must be signed in to change notification settings - Fork 1
/
runtests.d
50 lines (43 loc) · 1.38 KB
/
runtests.d
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
import std;
int main()
{
int result = runCommand(["dub", "test"]);
if (result != 0)
return result;
result = runCommand(["dub", "test", "--config=xgettext"]);
if (result != 0)
return result;
foreach (test; dirEntries("tests", SpanMode.shallow))
{
if (!test.isDir)
continue;
result = runTest(test.name);
if (result != 0)
return result;
}
return 0;
}
int runCommand(string[] command, string workDir = null)
{
writeln((workDir.length > 0 ? "cd " ~ workDir ~ " && " : ""), command.join(" "));
auto result = execute(command, null, Config.none, size_t.max, workDir);
writeln(result.output);
return result.status;
}
int runTest(string workDir)
{
auto result = runCommand(["dub", "build", "--config=i18n"], workDir);
if (result != 0)
return result;
// Check for translatable strings in .pot file.
foreach (potFile; dirEntries(buildPath(workDir, "po"), "*pot", SpanMode.shallow))
assert (potFile.readText.lineSplitter.count!(a => a.startsWith("msgid")) > 1,
"No translatable strings were extracted.");
foreach(lang; 0.. dirEntries(buildPath(workDir, "mo"), "*.mo", SpanMode.shallow).walkLength + 1)
{
result = runCommand(["dub", "run", "--", lang.to!string], workDir);
if (result != 0)
return result;
}
return 0;
}