Package: golang-github-hashicorp-go-slug Version: 0.7.0-1 Followup-For: Bug #997847 User: ubuntu-de...@lists.ubuntu.com Usertags: origin-ubuntu jammy ubuntu-patch Control: tags -1 patch
Dear Maintainer, In Ubuntu, the attached patch was applied to fix autopkgtest regressions: * debian/patches/disable-strange-tests.patch: Refresh the patch to include new tests that try to access testdata/archive-dir. This fixes an autopkgtest failure (LP: #1965429). Thanks, Nick
diff -Nru golang-github-hashicorp-go-slug-0.7.0/debian/patches/disable-strange-tests.patch golang-github-hashicorp-go-slug-0.7.0/debian/patches/disable-strange-tests.patch --- golang-github-hashicorp-go-slug-0.7.0/debian/patches/disable-strange-tests.patch 2021-10-05 14:31:50.000000000 -0400 +++ golang-github-hashicorp-go-slug-0.7.0/debian/patches/disable-strange-tests.patch 2022-03-17 14:36:15.000000000 -0400 @@ -1,11 +1,20 @@ Description: some tests require files in paths that are not compatible with Debian packaging in order to make life easier, these tests are disabled Author: Thorsten Alteholz <deb...@alteholz.de> -Index: golang-github-hashicorp-go-slug-0.7.0/slug_test.go -=================================================================== ---- golang-github-hashicorp-go-slug-0.7.0.orig/slug_test.go 2021-10-06 06:10:32.879315260 +0000 -+++ golang-github-hashicorp-go-slug-0.7.0/slug_test.go 2021-10-06 06:13:39.728065809 +0000 -@@ -14,231 +14,231 @@ +--- a/slug_test.go ++++ b/slug_test.go +@@ -2,10 +2,8 @@ + + import ( + "archive/tar" +- "bytes" + "compress/gzip" + "errors" +- "io" + "io/ioutil" + "os" + "path/filepath" +@@ -14,338 +12,338 @@ "testing" ) @@ -234,6 +243,113 @@ - t.Fatalf("\nexpect:\n%#v\n\nactual:\n%#v", expect, meta) - } -} +- +-func TestPackWithoutIgnoring(t *testing.T) { +- slug := bytes.NewBuffer(nil) +- +- // By default NewPacker() creates a Packer that does not use +- // .terraformignore or dereference symlinks. +- p, err := NewPacker() +- if err != nil { +- t.Fatalf("err: %v", err) +- } +- +- meta, err := p.Pack("testdata/archive-dir", slug) +- if err != nil { +- t.Fatalf("err: %v", err) +- } +- +- gzipR, err := gzip.NewReader(slug) +- if err != nil { +- t.Fatalf("err: %v", err) +- } +- +- tarR := tar.NewReader(gzipR) +- var ( +- fileList []string +- slugSize int64 +- ) +- +- for { +- hdr, err := tarR.Next() +- if err == io.EOF { +- break +- } +- if err != nil { +- t.Fatalf("err: %v", err) +- } +- +- fileList = append(fileList, hdr.Name) +- if hdr.Typeflag == tar.TypeReg || hdr.Typeflag == tar.TypeRegA { +- slugSize += hdr.Size +- } +- } +- +- // baz.txt would normally be ignored, but should not be +- var bazFound bool +- for _, file := range fileList { +- if file == "baz.txt" { +- bazFound = true +- } +- } +- if !bazFound { +- t.Fatal("expected file baz.txt to be present, but not found") +- } +- +- // .terraform/file.txt would normally be ignored, but should not be +- var dotTerraformFileFound bool +- for _, file := range fileList { +- if file == ".terraform/file.txt" { +- dotTerraformFileFound = true +- } +- } +- if !dotTerraformFileFound { +- t.Fatal("expected file .terraform/file.txt to be present, but not found") +- } +- +- // Check the metadata +- expect := &Meta{ +- Files: fileList, +- Size: slugSize, +- } +- if !reflect.DeepEqual(meta, expect) { +- t.Fatalf("\nexpect:\n%#v\n\nactual:\n%#v", expect, meta) +- } +-} +- +-func TestUnpack(t *testing.T) { +- // First create the slug file so we can try to unpack it. +- slug := bytes.NewBuffer(nil) +- +- if _, err := Pack("testdata/archive-dir", slug, true); err != nil { +- t.Fatalf("err: %v", err) +- } +- +- // Create a dir to unpack into. +- dst, err := ioutil.TempDir("", "slug") +- if err != nil { +- t.Fatalf("err: %v", err) +- } +- defer os.RemoveAll(dst) +- +- // Now try unpacking it. +- if err := Unpack(slug, dst); err != nil { +- t.Fatalf("err: %v", err) +- } +- +- // Verify all the files +- verifyFile(t, filepath.Join(dst, "foo.txt"), 0, "foo\n") +- verifyFile(t, filepath.Join(dst, "bar.txt"), 0, "bar\n") +- verifyFile(t, filepath.Join(dst, "sub", "bar.txt"), os.ModeSymlink, "../bar.txt") +- verifyFile(t, filepath.Join(dst, "sub", "zip.txt"), 0, "zip\n") +- +- // Check that we can set permissions properly +- verifyPerms(t, filepath.Join(dst, "foo.txt"), 0644) +- verifyPerms(t, filepath.Join(dst, "bar.txt"), 0644) +- verifyPerms(t, filepath.Join(dst, "sub", "zip.txt"), 0644) +- verifyPerms(t, filepath.Join(dst, "sub", "bar.txt"), 0644) +- verifyPerms(t, filepath.Join(dst, "exe"), 0755) +-} +//func TestPack(t *testing.T) { +// slug := bytes.NewBuffer(nil) +// @@ -459,13 +575,118 @@ +// t.Fatalf("\nexpect:\n%#v\n\nactual:\n%#v", expect, meta) +// } +//} ++// ++//func TestPackWithoutIgnoring(t *testing.T) { ++// slug := bytes.NewBuffer(nil) ++// ++// // By default NewPacker() creates a Packer that does not use ++// // .terraformignore or dereference symlinks. ++// p, err := NewPacker() ++// if err != nil { ++// t.Fatalf("err: %v", err) ++// } ++// ++// meta, err := p.Pack("testdata/archive-dir", slug) ++// if err != nil { ++// t.Fatalf("err: %v", err) ++// } ++// ++// gzipR, err := gzip.NewReader(slug) ++// if err != nil { ++// t.Fatalf("err: %v", err) ++// } ++// ++// tarR := tar.NewReader(gzipR) ++// var ( ++// fileList []string ++// slugSize int64 ++// ) ++// ++// for { ++// hdr, err := tarR.Next() ++// if err == io.EOF { ++// break ++// } ++// if err != nil { ++// t.Fatalf("err: %v", err) ++// } ++// ++// fileList = append(fileList, hdr.Name) ++// if hdr.Typeflag == tar.TypeReg || hdr.Typeflag == tar.TypeRegA { ++// slugSize += hdr.Size ++// } ++// } ++// ++// // baz.txt would normally be ignored, but should not be ++// var bazFound bool ++// for _, file := range fileList { ++// if file == "baz.txt" { ++// bazFound = true ++// } ++// } ++// if !bazFound { ++// t.Fatal("expected file baz.txt to be present, but not found") ++// } ++// ++// // .terraform/file.txt would normally be ignored, but should not be ++// var dotTerraformFileFound bool ++// for _, file := range fileList { ++// if file == ".terraform/file.txt" { ++// dotTerraformFileFound = true ++// } ++// } ++// if !dotTerraformFileFound { ++// t.Fatal("expected file .terraform/file.txt to be present, but not found") ++// } ++// ++// // Check the metadata ++// expect := &Meta{ ++// Files: fileList, ++// Size: slugSize, ++// } ++// if !reflect.DeepEqual(meta, expect) { ++// t.Fatalf("\nexpect:\n%#v\n\nactual:\n%#v", expect, meta) ++// } ++//} ++// ++//func TestUnpack(t *testing.T) { ++// // First create the slug file so we can try to unpack it. ++// slug := bytes.NewBuffer(nil) ++// ++// if _, err := Pack("testdata/archive-dir", slug, true); err != nil { ++// t.Fatalf("err: %v", err) ++// } ++// ++// // Create a dir to unpack into. ++// dst, err := ioutil.TempDir("", "slug") ++// if err != nil { ++// t.Fatalf("err: %v", err) ++// } ++// defer os.RemoveAll(dst) ++// ++// // Now try unpacking it. ++// if err := Unpack(slug, dst); err != nil { ++// t.Fatalf("err: %v", err) ++// } ++// ++// // Verify all the files ++// verifyFile(t, filepath.Join(dst, "foo.txt"), 0, "foo\n") ++// verifyFile(t, filepath.Join(dst, "bar.txt"), 0, "bar\n") ++// verifyFile(t, filepath.Join(dst, "sub", "bar.txt"), os.ModeSymlink, "../bar.txt") ++// verifyFile(t, filepath.Join(dst, "sub", "zip.txt"), 0, "zip\n") ++// ++// // Check that we can set permissions properly ++// verifyPerms(t, filepath.Join(dst, "foo.txt"), 0644) ++// verifyPerms(t, filepath.Join(dst, "bar.txt"), 0644) ++// verifyPerms(t, filepath.Join(dst, "sub", "zip.txt"), 0644) ++// verifyPerms(t, filepath.Join(dst, "sub", "bar.txt"), 0644) ++// verifyPerms(t, filepath.Join(dst, "exe"), 0755) ++//} - func TestPackWithoutIgnoring(t *testing.T) { - slug := bytes.NewBuffer(nil) -Index: golang-github-hashicorp-go-slug-0.7.0/terraformignore_test.go -=================================================================== ---- golang-github-hashicorp-go-slug-0.7.0.orig/terraformignore_test.go 2021-10-06 06:10:32.879315260 +0000 -+++ golang-github-hashicorp-go-slug-0.7.0/terraformignore_test.go 2021-10-06 06:10:32.875314987 +0000 + func TestUnpackDuplicateNoWritePerm(t *testing.T) { + dir, err := ioutil.TempDir("", "slug") +--- a/terraformignore_test.go ++++ b/terraformignore_test.go @@ -108,7 +108,8 @@ for i, p := range paths { match := matchIgnoreRule(p.path, ignoreRules)