From 97bc2af3b2aee7085294beb41c62998638eb67e8 Mon Sep 17 00:00:00 2001 From: Mooffie Date: Sun, 1 Jan 2017 18:19:48 +0200 Subject: [PATCH] extfs: rpm: make it testable. The way we make this helper testable is a bit different than with other helpers: While in other helpers we make it possible to override just one or two variables, here we make it possible to inject a code snippet into it. This is a more powerful approach which lets us override even functions, as will be shown in a following patch. (As for relocating the "AllTAGS=..." line: all non-declarative code needs to be moved past our new injection point, or else this code won't be affected by the injection. BTW, the "$1" on that line isn't used; a vestige from old days.) Signed-off-by: Mooffie --- src/vfs/extfs/helpers/rpm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/vfs/extfs/helpers/rpm b/src/vfs/extfs/helpers/rpm index 454a9c035..30d69263c 100755 --- a/src/vfs/extfs/helpers/rpm +++ b/src/vfs/extfs/helpers/rpm @@ -122,8 +122,6 @@ mcrpmfs_getOneTag() echo $AllTAGS | $SED "s/.*|${1}=//" | cut -d '|' -f 1 } -AllTAGS=`mcrpmfs_getAllNeededTags "$1"` - mcrpmfs_printOneMetaInfo() { if test "$3" = "raw"; then @@ -330,6 +328,11 @@ mcrpmfs_run () esac } +# Let the test framework override functions and variables. +[ -n "$MC_TEST_RPM_REWRITE" ] && . "$MC_TEST_RPM_REWRITE" + +AllTAGS=`mcrpmfs_getAllNeededTags "$1"` + umask 077 case "${param}" in list) mcrpmfs_list; exit 0;;