Hi there!
We had problems with the unit tests that the output to the console was mangled, lines would miss and the order of the output was not kept properly.
We found that the problem is related to using Python and git-bash in combination. Some users in Stackoverflow also indicate problems with php and git-bash.
The solution (workaround) is to use winpty, but with some special undocumented flags, because git-bash is not a windows console.
We describe the problem/solution as this:
git-bash is not a “proper” windows console. When Python is used therein (apparently a Python compiled with ncurses), the output is mangled: incomplete and out of the real order. To solve this, one can use winpty, which is bundled with git-bash. However, winpty requires, without options, a proper windows console, which git-bash is not, and it will through an error “stdin is not a tty”. Nevertheless, when using winpty with the flag “-Xallow-non-tty”, one can by-pass the check of whether it is a proper tty. However, it generates problems when it tries to rewind, which you can do with a tty, but not with a file. You can the use the winpty flag, “-Xplain” for this. Those flags are not documented and can only be found in the code of winpty. In any case, when winpty is executed like this, the screen output is beautiful (well just correct, but after having seen it wrong, it looks beautiful to me), the exit code (return code) of FreeCADCmd is not passed correctly to git-bash, so it detects it as “return 0 - success” even if tests fail. The solution I found is to use tee to put the same content that goes to the screen to a file, then grep is used against this file to search for FAILED and make the build fail if found (I am currently missing the -q flag to grep to make it quiet and avoid duplicating the FAILED line to the screen).
I leave here the work-around we found, in case it is useful for anybody:
winpty.exe -Xallow-non-tty -Xplain /C/Users/travis/build/FreeCAD/FreeCAD/build/bin/FreeCADCmd.exe --run-test 0 | tee runlog.txt
grep FAILED runlog.txt ; [ $? == 1 ] && echo "Build succeeded and tests passed!" || ( echo "Tests failed!" && false )
Our travis.yml is:
https://github.com/FreeCAD/FreeCAD/blob/master/.travis.yml
2 Likes