diff options
Diffstat (limited to 'test/system/070-build.bats')
-rw-r--r-- | test/system/070-build.bats | 90 |
1 files changed, 79 insertions, 11 deletions
diff --git a/test/system/070-build.bats b/test/system/070-build.bats index c45a661fe..26113e45c 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -509,6 +509,40 @@ EOF done } +# Regression test for #9867 +# Make sure that if you exclude everything in context dir, that +# the Containerfile/Dockerfile in the context dir are used +@test "podman build with ignore '*'" { + local tmpdir=$PODMAN_TMPDIR/build-test-$(random_string 10) + mkdir -p $tmpdir + + cat >$tmpdir/Containerfile <<EOF +FROM scratch +EOF + +cat >$tmpdir/.dockerignore <<EOF +* +EOF + + run_podman build -t build_test $tmpdir + + # Rename Containerfile to Dockerfile + mv $tmpdir/Containerfile $tmpdir/Dockerfile + + run_podman build -t build_test $tmpdir + + # Rename Dockerfile to foofile + mv $tmpdir/Dockerfile $tmpdir/foofile + + run_podman 125 build -t build_test $tmpdir + is "$output" ".*Dockerfile: no such file or directory" + + run_podman build -t build_test -f $tmpdir/foofile $tmpdir + + # Clean up + run_podman rmi -f build_test +} + @test "podman build - stdin test" { # Random workdir, and random string to verify build output workdir=/$(random_string 10) @@ -715,16 +749,9 @@ RUN echo $random_string EOF run_podman 125 build -t build_test --pull-never $tmpdir - # FIXME: this is just ridiculous. Even after #10030 and #10034, Ubuntu - # remote *STILL* flakes this test! It fails with the correct exit status, - # but the error output is 'Error: stream dropped, unexpected failure' - # Let's just stop checking on podman-remote. As long as it exits 125, - # we're happy. - if ! is_remote; then - is "$output" \ - ".*Error: error creating build container: quay.io/libpod/nosuchimage:nosuchtag: image not known" \ - "--pull-never fails with expected error message" - fi + is "$output" \ + ".*Error: error creating build container: quay.io/libpod/nosuchimage:nosuchtag: image not known" \ + "--pull-never fails with expected error message" } @test "podman build --logfile test" { @@ -817,7 +844,7 @@ EOF run_podman rmi -f build_test } -@test "podman build -f test " { +@test "podman build -f test" { tmpdir=$PODMAN_TMPDIR/build-test subdir=$tmpdir/subdir mkdir -p $subdir @@ -843,6 +870,44 @@ EOF run_podman rmi -f build_test } +@test "podman build .dockerignore failure test" { + tmpdir=$PODMAN_TMPDIR/build-test + subdir=$tmpdir/subdir + mkdir -p $subdir + + cat >$tmpdir/.dockerignore <<EOF +* +subdir +!*/sub1* +EOF + cat >$tmpdir/Containerfile <<EOF +FROM $IMAGE +COPY ./ ./ +COPY subdir ./ +EOF + run_podman 125 build -t build_test $tmpdir + is "$output" ".*Error: error building at STEP \"COPY subdir ./\"" ".dockerignore was ignored" +} + +@test "podman build .containerignore and .dockerignore test" { + tmpdir=$PODMAN_TMPDIR/build-test + mkdir -p $tmpdir + touch $tmpdir/test1 $tmpdir/test2 + cat >$tmpdir/.containerignore <<EOF +test2* +EOF + cat >$tmpdir/.dockerignore <<EOF +test1* +EOF + cat >$tmpdir/Containerfile <<EOF +FROM $IMAGE +COPY ./ /tmp/test/ +RUN ls /tmp/test/ +EOF + run_podman build -t build_test $tmpdir + is "$output" ".*test1" "test1 should exists in the final image" +} + function teardown() { # A timeout or other error in 'build' can leave behind stale images # that podman can't even see and which will cascade into subsequent @@ -850,6 +915,9 @@ function teardown() { run_podman '?' rm -a -f run_podman '?' rmi -f build_test + # Many of the tests above leave interim layers behind. Clean them up. + run_podman '?' image prune -f + basic_teardown } |