From 1250c19357519271f22e673c3f9cc883b0069773 Mon Sep 17 00:00:00 2001 From: Reid Priedhorsky <1682574+reidpr@users.noreply.github.com> Date: Thu, 13 Jun 2024 10:11:38 -0600 Subject: [PATCH] quick bug fixes for 0.38 (#1905) --- bin/ch-test | 17 +++++++++-------- test/build/50_dockerfile.bats | 3 ++- test/common.bash | 2 +- test/force-auto.py.in | 11 +++++++++++ 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/bin/ch-test b/bin/ch-test index 2788eed42..9e3c54693 100755 --- a/bin/ch-test +++ b/bin/ch-test @@ -299,16 +299,17 @@ pedantry_set () { if [[ $ch_pedantic == no ]]; then ch_pedantic= # proper boolean fi - # The motivation here is that in pedantic mode, we want to run all the - # tests we reasonably can. So, if the user *has* sudo, then default --sudo - # to yes. What is a little awkward is that “sudo -v” can generate a - # password prompt in the middle of the status output. An alternative is - # “sudo -nv”, which doesn’t; drawbacks are that you have to analyze the - # output (not exit code) and it generates a failed password log message if - # there is not already a sudo session going. + # Motivation here: In pedantic mode, we want to run all the tests we + # reasonably can. So, if the user *has* sudo, then default --sudo to yes. + # What is a little awkward is that “sudo true” can generate a password + # prompt in the middle of the status output. An alternative is “sudo -nv”, + # which doesn’t; drawbacks are that you have to analyze the output (not + # exit code) and it generates a failed password log message if there is + # not already a sudo session going. We also used to use “sudo -v”, which + # prompts for a password even if you have passwordless sudo set up. if [[ -n $ch_pedantic ]] \ && command -v sudo > /dev/null \ - && sudo -v > /dev/null 2>&1; then + && sudo true > /dev/null 2>&1; then use_sudo_default=yes else use_sudo_default= diff --git a/test/build/50_dockerfile.bats b/test/build/50_dockerfile.bats index e25f99d59..fc080a2b4 100644 --- a/test/build/50_dockerfile.bats +++ b/test/build/50_dockerfile.bats @@ -1160,7 +1160,8 @@ EOF [[ $status -ne 0 ]] [[ $output = *'error: no context because '?'-'?' given'* \ || $output = *'COPY failed: file not found in build context or'* \ - || $output = *'no such file or directory'* ]] + || $output = *'no such file or directory'* + || $output = *'not found'* ]] } diff --git a/test/common.bash b/test/common.bash index c9f7a1d30..c6d1d887f 100644 --- a/test/common.bash +++ b/test/common.bash @@ -454,7 +454,7 @@ fi # Do we have and want sudo? if [[ $CH_TEST_SUDO ]] \ && command -v sudo >/dev/null 2>&1 \ - && sudo -v > /dev/null 2>&1; then + && sudo true > /dev/null 2>&1; then # This isn’t super reliable; it returns true if we have *any* sudo # privileges, not specifically to run the commands we want to run. ch_have_sudo=yes diff --git a/test/force-auto.py.in b/test/force-auto.py.in index 9bfab7a39..0184fd2da 100644 --- a/test/force-auto.py.in +++ b/test/force-auto.py.in @@ -62,6 +62,7 @@ class Test(abc.ABC): base = None config = None scope = Scope.FULL + skip_reason = None prep_run = None runs = { Run.UNNEEDED_FAIL: "false", Run.UNNEEDED_WIN: "true" } @@ -83,6 +84,13 @@ class Test(abc.ABC): def build2_post_hook(self): return "" + @property + def skip(self): + if (self.skip_reason is None): + return "" + else: + return "skip '%s'" % self.skip_reason + def as_grep_files(self, grep_files, image, invert=False): cmds = [] for (re, path) in grep_files: @@ -168,6 +176,7 @@ echo "$output" # emit the test print(f""" @test "ch-image --force: {self}" {{ +{self.skip} scope {scope} {arch_excludes} @@ -234,6 +243,7 @@ class T_RHEL_UBI_8(RHEL8): class CentOS_8(RHEL8, EPEL_Mixin): prep_run = "dnf install -y epel-release" class T_CentOS_8_Stream(CentOS_8): + skip_reason = "issue #1904" # CentOS Stream pulls from quay.io per the CentOS wiki: # https://wiki.centos.org/FAQ/CentOSStream#What_artifacts_are_built.3F base = "quay.io/centos/centos:stream8" @@ -254,6 +264,7 @@ class T_Rocky_8(CentOS_8): class Fedora(RHEL8): config = "fedora" class T_Fedora_26(Fedora): + skip_reason = "issue #1904" # We would prefer to test the lowest supported --force version, 24, # but the ancient version of dnf it has doesn't fail the transaction when # a package fails so we test with 26 instead.