From: Prarit Bhargava <pra...@redhat.com> redhat/self-test: Add test to verify SPEC variables
This test looks at the spec file variable replacement code in redhat/genspec.sh and confirms that each variable begins with "SPEC". Signed-off-by: Prarit Bhargava <pra...@redhat.com> diff --git a/redhat/docs/makefile-changes.rst b/redhat/docs/makefile-changes.rst index blahblah..blahblah 100644 --- a/redhat/docs/makefile-changes.rst +++ b/redhat/docs/makefile-changes.rst @@ -46,6 +46,12 @@ external scripts. Variables in this file should be considered stable. Variables still may be deprecated and will follow the guidelines in "Deprecating variables and targets" section below. +Variable Naming +=============== + +Variables names prefixed with SPEC indicate that the variable is used +in redhat/kernel.spec.template (see redhat/genspec.sh). + Deprecating variables and targets ================================= diff --git a/redhat/genspec.sh b/redhat/genspec.sh index blahblah..blahblah 100755 --- a/redhat/genspec.sh +++ b/redhat/genspec.sh @@ -56,6 +56,7 @@ if [ "$PATCHLIST_URL" != "none" ]; then SPECPATCHLIST_CHANGELOG=1 fi +# self-test begin test -f "$SOURCES/$SPECFILE" && sed -i -e " s/%%SPECBUILDID%%/$SPECBUILDID/ @@ -70,6 +71,10 @@ test -f "$SOURCES/$SPECFILE" && s/%%SPECPATCHLIST_CHANGELOG%%/$SPECPATCHLIST_CHANGELOG/ s/%%SPECVERSION%%/$SPECVERSION/ s/%%SPECTARFILE_RELEASE%%/$SPECTARFILE_RELEASE/" "$SOURCES/$SPECFILE" +test -n "$RHSELFTESTDATA" && test -f "$SOURCES/$SPECFILE" && sed -i -e " + /%%SPECCHANGELOG%%/r $SOURCES/$SPECCHANGELOG + /%%SPECCHANGELOG%%/d" "$SOURCES/$SPECFILE" +# self-test end # We depend on work splitting of BUILDOPTS # shellcheck disable=SC2086 @@ -84,10 +89,6 @@ done # rest of the script can be ignored. See redhat/Makefile setup-source target for related # test changes. if [ -n "$RHSELFTESTDATA" ]; then - test -f "$SOURCES/$SPECFILE" && - sed -i -e " - /%%SPECCHANGELOG%%/r $SOURCES/$SPECCHANGELOG - /%%SPECCHANGELOG%%/d" "$SOURCES/$SPECFILE" exit 0 fi diff --git a/redhat/self-test/1006-verify-SPEC-variables.bats b/redhat/self-test/1006-verify-SPEC-variables.bats new file mode 100644 index blahblah..blahblah 100644 --- /dev/null +++ b/redhat/self-test/1006-verify-SPEC-variables.bats @@ -0,0 +1,25 @@ +#!/usr/bin/env bats + +@test "verify SPEC variables" { +# This test looks at the spec file variable replacement code in +# redhat/genspec.sh and confirms that each variable begins with "SPEC". + +# This looks at the code and replaces each / with a new-line character, removes +# any whitespace and entry entries beginning with valid "%%SPEC" or $"SPEC". +# "$SOURCES" lines are also okay as it is used to point to the changelog and +# the specfile. +awk '/# self-test begin/, /# self-test end/' $BATS_TEST_DIRNAME/../genspec.sh | grep -v "^#" | tr "/" "\n" | tr -d "\"" | sed -r '/^\s*$/d' | grep -v "%%SPEC" | grep -v "\$SPEC" | grep -v "\$SOURCES" | while read LINE +do + echo $LINE + case $(echo $LINE | xargs) in + s) ;; + d) ;; + "sed -i -e") ;; + *) + echo " " + echo "ERROR: Variables passed between genspec.sh and the spec file must begin with %%SPEC or \$SPEC." + exit 1 + ;; + esac +done +} -- https://gitlab.com/cki-project/kernel-ark/-/merge_requests/1728 _______________________________________________ kernel mailing list -- kernel@lists.fedoraproject.org To unsubscribe send an email to kernel-le...@lists.fedoraproject.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure