Skip to content

Commit

Permalink
Print the mismatching sha256sum values when frozen build rules fail.
Browse files Browse the repository at this point in the history
Previously the targets check_sha256sum_frozen and check_sha256sum_test would just emit that a sum mismatched. Now both hashes are printed. For example:

  Error: sha256sum checksum mismatch for file 'foo':
    expected: a8000f5f5431b05592d876f568c1c34dc73633a3de3d11eba30d87d03f4441e5
    actual:   cb04ccd886a4191d5ed6ddb3ac213b9d4eb9144b6d52880544d72ae6f055e432

PiperOrigin-RevId: 692327335
  • Loading branch information
meheffernan authored and copybara-github committed Nov 1, 2024
1 parent 4d8c944 commit 6b7c0dc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions xls/build_rules/xls_utilities.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ def _check_sha256sum_test_impl(ctx):
src.short_path,
),
"if [ $? -ne 0 ]; then",
"echo \"Error: sha256sum checksum mismatch for file '{}'.\""
"echo \"Error: sha256sum checksum mismatch for file '{}':"
.format(src.short_path),
" expected: {}".format(ctx.attr.sha256sum),
" actual: `sha256sum {} | cut -d ' ' -f1`\"".format(src.short_path),
"exit -1",
"fi",
"exit 0",
Expand Down Expand Up @@ -127,8 +129,10 @@ def _check_sha256sum_frozen_impl(ctx):
src_path,
),
"if [ $? -ne 0 ]; then",
"echo \"Error: sha256sum checksum mismatch for file '{}'.\""
"echo \"Error: sha256sum checksum mismatch for file '{}':"
.format(src_path),
" expected: {}".format(ctx.attr.sha256sum),
" actual: `sha256sum {} | cut -d ' ' -f1`\"".format(src_path),
"exit -1",
"fi",
"cat {} > {}".format(src_path, frozen_file.path),
Expand Down

0 comments on commit 6b7c0dc

Please sign in to comment.