test-locked-requirements: Improve logged output.

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 <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2019-08-24 16:21:21 -07:00 committed by Tim Abbott
parent a053a925b3
commit bd7ef1be51
2 changed files with 4 additions and 6 deletions

View File

@ -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 "

View File

@ -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