diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 2ca6fb4..8e229da 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -1069,23 +1069,20 @@ import std.encoding; import std.regex; - if (code_match != int.min) { - if (code != code_match) { - logInfo("Exit code %s doesn't match expected value %s", code, code_match); - throw new DustmiteMismatchException; - } else if (code != 0) { - throw new DustmiteMatchException; - } + if (code_match != int.min && code != code_match) { + logInfo("Exit code %s doesn't match expected value %s", code, code_match); + throw new DustmiteMismatchException; } - if (regex_match.length > 0) { - if (!match(output.sanitize, regex_match)) { - logInfo("Output doesn't match regex:"); - logInfo("%s", output); - throw new DustmiteMismatchException; - } else if (code != 0) { - throw new DustmiteMatchException; - } + if (regex_match.length > 0 && !match(output.sanitize, regex_match)) { + logInfo("Output doesn't match regex:"); + logInfo("%s", output); + throw new DustmiteMismatchException; + } + + if (code != 0 && code_match != int.min || regex_match.length > 0) { + logInfo("Tool failed, but matched either exit code or output - counting as match."); + throw new DustmiteMatchException; } }; }