From df3c9e2735f02a7fe8cd80db4db00fec8e13d25f Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 18 Aug 2021 08:23:43 -0700 Subject: [PATCH] =?UTF-8?q?diff=5Ftest:=20add=20ability=20for=20caller=20t?= =?UTF-8?q?o=20specify=20a=20message=20printed=20on=20fai=E2=80=A6=20(#307?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Useful for the use case of a pair of .test and .update targets for checked-in golden files --- rules/diff_test.bzl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rules/diff_test.bzl b/rules/diff_test.bzl index 71faf40..acde2ea 100644 --- a/rules/diff_test.bzl +++ b/rules/diff_test.bzl @@ -58,7 +58,7 @@ if "!RF2!" equ "" ( fc.exe 2>NUL 1>NUL /B "!RF1!" "!RF2!" if %ERRORLEVEL% neq 0 ( if %ERRORLEVEL% equ 1 ( - echo>&2 FAIL: files "{file1}" and "{file2}" differ + echo>&2 FAIL: files "{file1}" and "{file2}" differ. {fail_msg} exit /b 1 ) else ( fc.exe /B "!RF1!" "!RF2!" @@ -66,6 +66,7 @@ if %ERRORLEVEL% neq 0 ( ) ) """.format( + fail_msg = ctx.attr.failure_message, file1 = _runfiles_path(ctx.file.file1), file2 = _runfiles_path(ctx.file.file2), ), @@ -95,10 +96,11 @@ else exit 1 fi if ! diff "$RF1" "$RF2"; then - echo >&2 "FAIL: files \"{file1}\" and \"{file2}\" differ" + echo >&2 "FAIL: files \"{file1}\" and \"{file2}\" differ. {fail_msg}" exit 1 fi """.format( + fail_msg = ctx.attr.failure_message, file1 = _runfiles_path(ctx.file.file1), file2 = _runfiles_path(ctx.file.file2), ), @@ -112,6 +114,7 @@ fi _diff_test = rule( attrs = { + "failure_message": attr.string(), "file1": attr.label( allow_single_file = True, mandatory = True,