diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 666b79d..3648544 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -2239,6 +2239,7 @@ string m_programRegex; string m_testPackage; bool m_combined; + bool m_noRedirect; } this() @safe pure nothrow @@ -2266,6 +2267,7 @@ args.getopt("program-regex", &m_programRegex, ["A regular expression used to match against the program output"]); args.getopt("test-package", &m_testPackage, ["Perform a test run - usually only used internally"]); args.getopt("combined", &m_combined, ["Builds multiple packages with one compiler run"]); + args.getopt("no-redirect", &m_noRedirect, ["Don't redirect stdout/stderr streams of the test command"]); super.prepare(args); // speed up loading when in test mode @@ -2382,7 +2384,7 @@ logInfo("Executing dustmite..."); auto testcmd = appender!string(); - testcmd.formattedWrite("%s dustmite --vquiet --test-package=%s --build=%s --config=%s", + testcmd.formattedWrite("%s dustmite --test-package=%s --build=%s --config=%s", thisExePath, prj.name, m_buildType, m_buildConfig); if (m_compilerName.length) testcmd.formattedWrite(" \"--compiler=%s\"", m_compilerName); @@ -2394,9 +2396,17 @@ if (m_programStatusCode != int.min) testcmd.formattedWrite(" --program-status=%s", m_programStatusCode); if (m_programRegex.length) testcmd.formattedWrite(" \"--program-regex=%s\"", m_programRegex); if (m_combined) testcmd ~= " --combined"; + + // --vquiet swallows dustmite's output ... + if (!m_noRedirect) testcmd ~= " --vquiet"; + // TODO: pass *all* original parameters logDiagnostic("Running dustmite: %s", testcmd); - auto dmpid = spawnProcess(["dustmite", path.toNativeString(), testcmd.data]); + + string[] extraArgs; + if (m_noRedirect) extraArgs ~= "--no-redirect"; + const cmd = "dustmite" ~ extraArgs ~ [path.toNativeString(), testcmd.data]; + auto dmpid = spawnProcess(cmd); return dmpid.wait(); } return 0; diff --git a/test/dustmite-no-redirect-test/.no_build b/test/dustmite-no-redirect-test/.no_build new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/dustmite-no-redirect-test/.no_build diff --git a/test/dustmite-no-redirect-test/project/dub.json b/test/dustmite-no-redirect-test/project/dub.json new file mode 100644 index 0000000..32fa835 --- /dev/null +++ b/test/dustmite-no-redirect-test/project/dub.json @@ -0,0 +1,3 @@ +{ + "name": "dustmite-no-redirect-test" +} diff --git a/test/dustmite-no-redirect-test/project/source/app.d b/test/dustmite-no-redirect-test/project/source/app.d new file mode 100644 index 0000000..3ba959a --- /dev/null +++ b/test/dustmite-no-redirect-test/project/source/app.d @@ -0,0 +1,6 @@ +extern(C) int printf(const scope char*, ...); + +void main() +{ + printf("This text should be shown!\n"); +} diff --git a/test/dustmite-no-redirect.sh b/test/dustmite-no-redirect.sh new file mode 100755 index 0000000..33f25e8 --- /dev/null +++ b/test/dustmite-no-redirect.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +if ! command -v dustmite &> /dev/null +then + echo "Skipping test because dustmite is not installed!" + exit 0 +fi + +. $(dirname "${BASH_SOURCE[0]}")/common.sh + +DM_TEST="$CURR_DIR/dustmite-no-redirect-test/project" +DM_TMP="$DM_TEST-dusting" +EXPECTED="This text should be shown!" +LOG="$DM_TEST.log" + +rm -rf $DM_TMP $DM_TMP.* + +$DUB --root=$DM_TEST dustmite --no-redirect --program-status=1 $DM_TMP &> $LOG || true + +if ! grep -q "$EXPECTED" "$LOG" +then + cat $LOG + die 1 +fi + +rm -rf $DM_TMP $DM_TMP.* $LOG