On Mon Mar 10 14:42:07 2025 +0000, eric pouech wrote:
you likely need to reopen console (CONOUT$) attached to cmd.exe not the current output handle as the MODE command deals with device, this command likely starts by opening the corresponding device (console, lpt serial line...) for the tests, beware that cmd.exe output are localized so comparing command's output will not work but you could (as tests):
- add a test for a non existent device
- add a test for a non conforming CON configuration
- try changing lines & columns and check in 'MODE CON:' output that the
numerical values are present in output (findstr) and put the tests dealing with errorlevel and return code in the relevant part of both test_builtins.cmd and test_builtins.bat (more functional testing, like actually changing the screen buffer size, could go elsewhere only in the .cmd tests file) in the code, from the behavior of lots of other builtin commands, it's very unlikely that the errorlevel is set with GetLastError()
CONOUT$ is a good idea, yes. CON doesn't work (neither wine nor windows), but the MODE command seems to do string comparison on the device name, so hardcoding CONOUT$ instead is fine.
You're right about errorlevel, it's just 0 or -1. Fixed.
Setting console size feels a bit like scope creep, but if it's the only way to test the thing, then so be it.