Skip to content

Commit 26c4852

Browse files
committed
Fix #1933: Add dustmite arguments: --compiler-text, --linker-text, --program-text
1 parent 5f4ea8e commit 26c4852

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

scripts/fish-completion/dub.fish

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,13 @@ end
8282

8383
for cmd in dustmite
8484
complete -c dub -n "contains '$cmd' (commandline -poc)" -l compiler-status -x -d "Expected compiler status code"
85+
complete -c dub -n "contains '$cmd' (commandline -poc)" -l compiler-text -x -d "Compiler output (sub) string"
8586
complete -c dub -n "contains '$cmd' (commandline -poc)" -l compiler-regex -x -d "Compiler output regular expression"
8687
complete -c dub -n "contains '$cmd' (commandline -poc)" -l linker-status -x -d "Expected linker status code"
88+
complete -c dub -n "contains '$cmd' (commandline -poc)" -l linker-text -x -d "Linker output (sub) string"
8789
complete -c dub -n "contains '$cmd' (commandline -poc)" -l linker-regex -x -d "Linker output regular expression"
8890
complete -c dub -n "contains '$cmd' (commandline -poc)" -l program-status -x -d "Expected program status code"
91+
complete -c dub -n "contains '$cmd' (commandline -poc)" -l program-text -x -d "Program output (sub) string"
8992
complete -c dub -n "contains '$cmd' (commandline -poc)" -l program-regex -x -d "Program output regular expression"
9093
complete -c dub -n "contains '$cmd' (commandline -poc)" -l test-package -x -d "Perform a test run"
9194
end

scripts/zsh-completion/_dub

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,10 +250,13 @@ _dub_dustmite() {
250250
local localArgs=(
251251
':target directory:_directories'
252252
'--compiler-status=[The expected status code of the compiler run]:status code: '
253+
'--compiler-text=[A (sub) string used to match against the compiler output]:regex: '
253254
'--compiler-regex=[A regular expression used to match against the compiler output]:regex: '
254255
'--linker-status=[The expected status code of the linker run]:status code: '
256+
'--linker-text=[A (sub) string used to match against the linker output]:text: '
255257
'--linker-regex=[A regular expression used to match against the linker output]:regex: '
256258
'--program-status=[The expected status code of the built executable]:status code: '
259+
'--program-text=[A (sub) string used to match against the program output]:text: '
257260
'--program-regex=[A regular expression used to match against the program output]:regex: '
258261
'--[End of dub arguments, the following will be sent to the program]'
259262
)

source/dub/commandline.d

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2686,8 +2686,11 @@ class DustmiteCommand : PackageBuildCommand {
26862686
int m_compilerStatusCode = int.min;
26872687
int m_linkerStatusCode = int.min;
26882688
int m_programStatusCode = int.min;
2689+
string m_compilerText;
26892690
string m_compilerRegex;
2691+
string m_linkerText;
26902692
string m_linkerRegex;
2693+
string m_programText;
26912694
string m_programRegex;
26922695
string m_testPackage;
26932696
bool m_noRedirect;
@@ -2714,10 +2717,13 @@ class DustmiteCommand : PackageBuildCommand {
27142717
override void prepare(scope CommandArgs args)
27152718
{
27162719
args.getopt("compiler-status", &m_compilerStatusCode, ["The expected status code of the compiler run"]);
2720+
args.getopt("compiler-text", &m_compilerText, ["A (sub) string used to match against the compiler output"]);
27172721
args.getopt("compiler-regex", &m_compilerRegex, ["A regular expression used to match against the compiler output"]);
27182722
args.getopt("linker-status", &m_linkerStatusCode, ["The expected status code of the linker run"]);
2723+
args.getopt("linker-text", &m_linkerText, ["A (sub) string used to match against the linker output"]);
27192724
args.getopt("linker-regex", &m_linkerRegex, ["A regular expression used to match against the linker output"]);
27202725
args.getopt("program-status", &m_programStatusCode, ["The expected status code of the built executable"]);
2726+
args.getopt("program-text", &m_programText, ["A (sub) string used to match against the program output"]);
27212727
args.getopt("program-regex", &m_programRegex, ["A regular expression used to match against the program output"]);
27222728
args.getopt("test-package", &m_testPackage, ["Perform a test run - usually only used internally"]);
27232729
args.getopt("combined", &this.baseSettings.combined, ["Builds multiple packages with one compiler run"]);
@@ -2755,9 +2761,9 @@ class DustmiteCommand : PackageBuildCommand {
27552761
gensettings.run = m_programStatusCode != int.min || m_programRegex.length;
27562762
gensettings.runArgs = app_args;
27572763
gensettings.force = true;
2758-
gensettings.compileCallback = check(m_compilerStatusCode, m_compilerRegex);
2759-
gensettings.linkCallback = check(m_linkerStatusCode, m_linkerRegex);
2760-
gensettings.runCallback = check(m_programStatusCode, m_programRegex);
2764+
gensettings.compileCallback = check(m_compilerStatusCode, m_compilerText, m_compilerRegex);
2765+
gensettings.linkCallback = check(m_linkerStatusCode, m_linkerText, m_linkerRegex);
2766+
gensettings.runCallback = check(m_programStatusCode, m_programText, m_programRegex);
27612767
try dub.generateProject("build", gensettings);
27622768
catch (DustmiteMismatchException) {
27632769
logInfoNoTag("Dustmite test doesn't match.");
@@ -2849,10 +2855,13 @@ class DustmiteCommand : PackageBuildCommand {
28492855
if (m_compilerName.length) testcmd.formattedWrite(" \"--compiler=%s\"", m_compilerName);
28502856
if (m_arch.length) testcmd.formattedWrite(" --arch=%s", m_arch);
28512857
if (m_compilerStatusCode != int.min) testcmd.formattedWrite(" --compiler-status=%s", m_compilerStatusCode);
2858+
if (m_compilerText.length) testcmd.formattedWrite(" \"--compiler-text=%s\"", m_compilerText);
28522859
if (m_compilerRegex.length) testcmd.formattedWrite(" \"--compiler-regex=%s\"", m_compilerRegex);
28532860
if (m_linkerStatusCode != int.min) testcmd.formattedWrite(" --linker-status=%s", m_linkerStatusCode);
2861+
if (m_linkerText.length) testcmd.formattedWrite(" \"--linker-text=%s\"", m_linkerText);
28542862
if (m_linkerRegex.length) testcmd.formattedWrite(" \"--linker-regex=%s\"", m_linkerRegex);
28552863
if (m_programStatusCode != int.min) testcmd.formattedWrite(" --program-status=%s", m_programStatusCode);
2864+
if (m_programText.length) testcmd.formattedWrite(" \"--program-text=%s\"", m_programText);
28562865
if (m_programRegex.length) testcmd.formattedWrite(" \"--program-regex=%s\"", m_programRegex);
28572866
if (this.baseSettings.combined) testcmd ~= " --combined";
28582867

@@ -2875,7 +2884,7 @@ class DustmiteCommand : PackageBuildCommand {
28752884
return 0;
28762885
}
28772886

2878-
void delegate(int, string) check(int code_match, string regex_match)
2887+
void delegate(int, string) check(int code_match, string string_match, string regex_match)
28792888
{
28802889
return (code, output) {
28812890
import std.encoding;
@@ -2888,8 +2897,14 @@ class DustmiteCommand : PackageBuildCommand {
28882897
throw new DustmiteMismatchException;
28892898
}
28902899

2900+
if (string_match.length > 0 && !output.sanitize.canFind(string_match)) {
2901+
logInfo("Output doesn't contain (sub) string %s:", string_match);
2902+
logInfo("%s", output);
2903+
throw new DustmiteMismatchException;
2904+
}
2905+
28912906
if (regex_match.length > 0 && !match(output.sanitize, regex_match)) {
2892-
logInfo("Output doesn't match regex:");
2907+
logInfo("Output doesn't match regex %s:", regex_match);
28932908
logInfo("%s", output);
28942909
throw new DustmiteMismatchException;
28952910
}

0 commit comments

Comments
 (0)