From d29655bf596b45fe7f8fb03dc1ecfac0154a1435 Mon Sep 17 00:00:00 2001 From: TomSweeneyRedHat Date: Tue, 23 Jun 2020 15:40:17 -0400 Subject: [PATCH] Add bud regression tests We recently made a couple of commits to the imagebuilder project to address #2345 and #2192. Tests were created in that project, but I thought it best to add some regression tests here in Buildah too. FYI: @petr-motejlek and @tachoknight Signed-off-by: TomSweeneyRedHat --- tests/bud.bats | 12 ++++++++++++ tests/bud/copy-chown/Containerfile.chown_user | 8 ++++++++ tests/bud/dupe-arg-env-name/Containerfile | 7 +++++++ 3 files changed, 27 insertions(+) create mode 100644 tests/bud/copy-chown/Containerfile.chown_user create mode 100644 tests/bud/dupe-arg-env-name/Containerfile diff --git a/tests/bud.bats b/tests/bud.bats index d17ba83268a..a8ad48e4f0f 100644 --- a/tests/bud.bats +++ b/tests/bud.bats @@ -2104,3 +2104,15 @@ EOM run_buildah --log-level "warn" bud --signature-policy ${TESTSDIR}/policy.json -t test ${TESTSDIR}/bud/build-arg expect_output --substring 'missing .+ build argument' } + +@test "bud arg and env var with same name" { + # Regresion test for https://github.com/containers/buildah/issues/2345 + run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t testctr ${TESTSDIR}/bud/dupe-arg-env-name + expect_output --substring "https://example.org/bar" +} + +@test "bud copy chown with newuser" { + # Regression test for https://github.com/containers/buildah/issues/2192 + run_buildah bud --signature-policy ${TESTSDIR}/policy.json -t testctr -f ${TESTSDIR}/bud/copy-chown/Containerfile.chown_user ${TESTSDIR}/bud/copy-chown + expect_output --substring "myuser myuser" +} diff --git a/tests/bud/copy-chown/Containerfile.chown_user b/tests/bud/copy-chown/Containerfile.chown_user new file mode 100644 index 00000000000..08a2e58c9f9 --- /dev/null +++ b/tests/bud/copy-chown/Containerfile.chown_user @@ -0,0 +1,8 @@ +FROM ubuntu:latest + +ENV MYUSER=myuser + +RUN useradd --create-home --home /"${MYUSER}" "${MYUSER}" +COPY --chown="${MYUSER}" ./copychown.txt /somewhere + +RUN ls -alF /somewhere diff --git a/tests/bud/dupe-arg-env-name/Containerfile b/tests/bud/dupe-arg-env-name/Containerfile new file mode 100644 index 00000000000..62bbf1249f7 --- /dev/null +++ b/tests/bud/dupe-arg-env-name/Containerfile @@ -0,0 +1,7 @@ +FROM centos:8 +ARG FOO=bar +ARG WEBROOT=https://example.org/ + +ENV WEBROOT="$WEBROOT$FOO" + +RUN echo "${WEBROOT}"