upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/selftest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/selftest.cpp')
-rw-r--r--src/selftest.cpp30
1 files changed, 3 insertions, 27 deletions
diff --git a/src/selftest.cpp b/src/selftest.cpp
index 6792ae7..b733c60 100644
--- a/src/selftest.cpp
+++ b/src/selftest.cpp
@@ -286,33 +286,9 @@ static int RunWalletKeyPoolSelfTest()
286 return nFail == 0 ? 0 : 1; 286 return nFail == 0 ? 0 : 1;
287} 287}
288 288
289// A -mwindows binary starts with no console attached, so stdout goes nowhere 289// AttachTerminal() moved to util.h: the wallet phrase commands need it too,
290// even when it was launched from a terminal. Borrow the caller's console for 290// and two copies of a console-attach that must get its one condition right is
291// the duration of the self-test. Nothing to do on Linux, where stdout is 291// one copy too many.
292// already connected.
293static void AttachTerminal()
294{
295#ifdef _WIN32
296 // Only when there is nowhere for stdout to go. If the caller redirected it
297 // to a file or a pipe -- which is what `make tests > log` and any CI does --
298 // that handle is inherited and already works, and reopening it on CONOUT$
299 // would take the output away from the file and put it on the screen. That
300 // was the first version of this fix, and it broke the one case that
301 // mattered.
302 HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
303 if (hOut != NULL && hOut != INVALID_HANDLE_VALUE)
304 return;
305
306 if (AttachConsole(ATTACH_PARENT_PROCESS))
307 {
308 // Return values ignored on purpose: if the reopen fails there is
309 // nowhere left to report it, and the exit status still carries the
310 // result.
311 freopen("CONOUT$", "w", stdout);
312 freopen("CONOUT$", "w", stderr);
313 }
314#endif
315}
316 292
317static int RunWalletHDSelfTest() 293static int RunWalletHDSelfTest()
318{ 294{