From bd7ef1be51d18979bafadd22e44c48de75bffd3d Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 24 Aug 2019 16:21:21 -0700 Subject: [PATCH] test-locked-requirements: Improve logged output. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Run pip-compile with --quiet so we don’t have to redirect its stderr; then we can see any exceptions it might throw. Print any resulting diff in the right order and without extra newlines separating each line. Signed-off-by: Anders Kaseorg --- tools/test-locked-requirements | 8 +++----- tools/update-locked-requirements | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/test-locked-requirements b/tools/test-locked-requirements index 43649564c0..6e3cbb1093 100755 --- a/tools/test-locked-requirements +++ b/tools/test-locked-requirements @@ -31,8 +31,7 @@ def print_diff(path_file1, path_file2): fromfile=path_file1, tofile=path_file2, ) - for line in diff: - print(line) + sys.stdout.writelines(diff) def test_locked_requirements(tmp_dir): # type: (str) -> bool @@ -44,8 +43,7 @@ def test_locked_requirements(tmp_dir): locked_file = os.path.join(REQS_DIR, fn) test_locked_file = os.path.join(tmp_dir, fn) shutil.copyfile(locked_file, test_locked_file) - subprocess.check_call([os.path.join(TOOLS_DIR, 'update-locked-requirements'), '--output-dir', tmp_dir], - stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + subprocess.check_call([os.path.join(TOOLS_DIR, 'update-locked-requirements'), '--output-dir', tmp_dir]) same = True for fn in LOCKED_REQS_FILE_NAMES: @@ -114,7 +112,7 @@ def main(): for fn in LOCKED_REQS_FILE_NAMES: locked_file = os.path.join(REQS_DIR, fn) test_locked_file = os.path.join(tmp_dir, fn) - print_diff(test_locked_file, locked_file) + print_diff(locked_file, test_locked_file) # Flush the output to ensure we print the error at the end. sys.stdout.flush() raise Exception("It looks like you have updated some python dependencies but haven't " diff --git a/tools/update-locked-requirements b/tools/update-locked-requirements index e1dfec6693..1fe2c77f73 100755 --- a/tools/update-locked-requirements +++ b/tools/update-locked-requirements @@ -12,7 +12,7 @@ compile_requirements () { output="$2" python_version="$3" - pip-compile --output-file "$output" "$source" + pip-compile --quiet --output-file "$output" "$source" # Remove the editable flag. It's there because pip-compile can't # yet do without it (see