diff options
author | Peter Wu <peter@lekensteyn.nl> | 2019-03-29 00:26:41 +0000 |
---|---|---|
committer | Dario Lombardo <lomato@gmail.com> | 2019-03-31 20:54:21 +0000 |
commit | 8a283325d4d251ef933bdf0897b98b2185ee2ecc (patch) | |
tree | dedc932ca3263c15882b4c86c0b153d001b0e2d3 | |
parent | 511867cdf4a56da9a261cd57e75873ae89a21d8e (diff) |
travis: fix missing msbuild output on Windows
For some reason the CMake output to Python is missing, no matter how
hard I try. Use an alternative approach instead where Python executes
CMake and filters the output without relying on pipes in Bash.
Change-Id: I21b8b709c3a944fbd3b07e7fac59702735dd83a4
Reviewed-on: https://code.wireshark.org/review/32628
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
-rw-r--r-- | .travis.yml | 6 | ||||
-rwxr-xr-x | tools/filter-msbuild.py | 88 |
2 files changed, 59 insertions, 35 deletions
diff --git a/.travis.yml b/.travis.yml index 5e0197779b..4a5d9d9ef2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -115,10 +115,10 @@ before_script: script: # Enable parallelism for msbuild too (since CMake 3.12; ninja does not need it) - export CMAKE_BUILD_PARALLEL_LEVEL=0 - - if [ "$TRAVIS_OS_NAME" == "windows" ]; then build_filter=../tools/filter-msbuild.py; else build_filter=cat; fi + - if [ "$TRAVIS_OS_NAME" == "windows" ]; then cmake() { ../tools/filter-msbuild.py cmake "$@"; }; fi # Invoke ninja (Linux/macOS, --config is ignored) or msbuild (Windows) - - cmake --build . --config RelWithDebInfo | $build_filter - - cmake --build . --config RelWithDebInfo --target test-programs | $build_filter + - cmake --build . --config RelWithDebInfo + - cmake --build . --config RelWithDebInfo --target test-programs - if [ "$PCAP" = "OFF" ]; then export PYTEST_ADDOPTS=--skip-missing-programs=dumpcap,rawshark; fi - if [ "$TRAVIS_OS_NAME" == "linux" -a "$PCAP" = "ON" ]; then sudo setcap "CAP_NET_RAW+eip CAP_NET_ADMIN+eip" run/dumpcap; fi - pytest diff --git a/tools/filter-msbuild.py b/tools/filter-msbuild.py index 560ea1646c..c58541f17b 100755 --- a/tools/filter-msbuild.py +++ b/tools/filter-msbuild.py @@ -4,38 +4,62 @@ # Copyright (C) 2019 Peter Wu <peter@lekensteyn.nl> # SPDX-License-Identifier: GPL-2.0-or-later +import subprocess import sys -# If an important message is present, print it with a newline. -# Otherwise skip the newline but print the next line with a carriage return. -# If the end of build is reached, just print the trailing messages (includes -# elapsed time, warning/error counts, etc.). - -start_of_line = '' -end_of_build = False -for line in sys.stdin: - line = line.rstrip('\r\n') - - if line.startswith('Build succeeded.'): - end_of_build = True - is_important = end_of_build or any([ - ': error ' in line, - ': warning ' in line, - '-- FAILED.' in line, - ]) - - if is_important: - eol = '\n' - if start_of_line == '\r': - start_of_line = '\n' - else: - eol = '' - - sys.stdout.write("%s%s%s" % (start_of_line, line, eol)) - sys.stdout.flush() - - if is_important: - start_of_line = '' - else: - start_of_line = '\r' +def print_lines(f): + # If an important message is present, print it with a newline. + # Otherwise skip the newline but print the next line with a carriage return. + # If the end of build is reached, just print the trailing messages (includes + # elapsed time, warning/error counts, etc.). + + start_of_line = '' + end_of_build = False + for line in iter(f.readline, ''): + line = line.rstrip('\r\n') + + if line.startswith('Build succeeded.'): + end_of_build = True + is_important = end_of_build or any([ + ': error ' in line, + ': warning ' in line, + '-- FAILED.' in line, + ]) + + if is_important: + eol = '\n' + if start_of_line == '\r': + start_of_line = '\n' + else: + eol = '' + + sys.stdout.write("%s%s%s" % (start_of_line, line, eol)) + sys.stdout.flush() + + if is_important: + start_of_line = '' + else: + start_of_line = '\r' + + # If the last line was not important, its LF was omitted so print it. + if not is_important: + sys.stdout.write('\n') + + +command = sys.argv[1:] +if command: + # Execute the given command and parse its output. + proc = subprocess.Popen(command, + bufsize=1, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + universal_newlines=True + ) + try: + print_lines(proc.stdout) + finally: + sys.exit(proc.wait()) +else: + # Assume a file read from stdin. + print_lines(sys.stdin) |