From 02cc0884c01dc596ec99d31a2843ba6cf3acad69 Mon Sep 17 00:00:00 2001 From: Alberto Carretero Date: Mon, 26 Feb 2024 12:37:07 +0100 Subject: [PATCH] change underscore to dash in file names --- internal/deb/extract_test.go | 76 +++++++++++++-------------- internal/slicer/slicer_test.go | 96 +++++++++++++++++----------------- internal/testutil/pkgdata.go | 6 +-- 3 files changed, 89 insertions(+), 89 deletions(-) diff --git a/internal/deb/extract_test.go b/internal/deb/extract_test.go index 7749f839..564e6c83 100644 --- a/internal/deb/extract_test.go +++ b/internal/deb/extract_test.go @@ -33,8 +33,8 @@ var extractTests = []extractTest{{ "/dir/file": []deb.ExtractInfo{{ Path: "/dir/file", }}, - "/dir/other_file": []deb.ExtractInfo{{ - Path: "/dir/other_file", + "/dir/other-file": []deb.ExtractInfo{{ + Path: "/dir/other-file", }}, "/dir/several/levels/deep/file": []deb.ExtractInfo{{ Path: "/dir/several/levels/deep/file", @@ -42,8 +42,8 @@ var extractTests = []extractTest{{ "/dir/nested/": []deb.ExtractInfo{{ Path: "/dir/nested/", }}, - "/other_dir/": []deb.ExtractInfo{{ - Path: "/other_dir/", + "/other-dir/": []deb.ExtractInfo{{ + Path: "/other-dir/", }}, }, }, @@ -51,12 +51,12 @@ var extractTests = []extractTest{{ "/dir/": "dir 0755", "/dir/file": "file 0644 cc55e2ec", "/dir/nested/": "dir 0755", - "/dir/other_file": "file 0644 63d5dd49", + "/dir/other-file": "file 0644 63d5dd49", "/dir/several/": "dir 0755", "/dir/several/levels/": "dir 0755", "/dir/several/levels/deep/": "dir 0755", "/dir/several/levels/deep/file": "file 0644 6bc26dff", - "/other_dir/": "dir 0755", + "/other-dir/": "dir 0755", }, }, { @@ -65,11 +65,11 @@ var extractTests = []extractTest{{ options: deb.ExtractOptions{ Extract: map[string][]deb.ExtractInfo{ "/dir/file": []deb.ExtractInfo{{ - Path: "/foo/file_copy", + Path: "/foo/file-copy", Mode: 0600, }}, "/dir/several/levels/deep/": []deb.ExtractInfo{{ - Path: "/foo/bar/dir_copy", + Path: "/foo/bar/dir-copy", Mode: 0700, }}, }, @@ -77,8 +77,8 @@ var extractTests = []extractTest{{ result: map[string]string{ "/foo/": "dir 0755", "/foo/bar/": "dir 0755", - "/foo/bar/dir_copy/": "dir 0700", - "/foo/file_copy": "file 0600 cc55e2ec", + "/foo/bar/dir-copy/": "dir 0700", + "/foo/file-copy": "file 0600 cc55e2ec", }, }, { @@ -87,18 +87,18 @@ var extractTests = []extractTest{{ options: deb.ExtractOptions{ Extract: map[string][]deb.ExtractInfo{ "/dir/file": []deb.ExtractInfo{{ - Path: "/dir/foo/file_copy_1", + Path: "/dir/foo/file-copy-1", }, { - Path: "/dir/bar/file_copy_2", + Path: "/dir/bar/file-copy-2", }}, }, }, result: map[string]string{ "/dir/": "dir 0755", "/dir/bar/": "dir 0755", - "/dir/bar/file_copy_2": "file 0644 cc55e2ec", + "/dir/bar/file-copy-2": "file 0644 cc55e2ec", "/dir/foo/": "dir 0755", - "/dir/foo/file_copy_1": "file 0644 cc55e2ec", + "/dir/foo/file-copy-1": "file 0644 cc55e2ec", }, }, { summary: "Globbing a single dir level", @@ -112,7 +112,7 @@ var extractTests = []extractTest{{ }, result: map[string]string{ "/dir/": "dir 0755", - "/other_dir/": "dir 0755", + "/other-dir/": "dir 0755", "/parent/": "dir 01777", "/usr/": "dir 0755", }, @@ -131,8 +131,8 @@ var extractTests = []extractTest{{ "/dir/file": "file 0644 cc55e2ec", "/dir/nested/": "dir 0755", "/dir/nested/file": "file 0644 84237a05", - "/dir/nested/other_file": "file 0644 6b86b273", - "/dir/other_file": "file 0644 63d5dd49", + "/dir/nested/other-file": "file 0644 6b86b273", + "/dir/other-file": "file 0644 63d5dd49", "/dir/several/": "dir 0755", "/dir/several/levels/": "dir 0755", "/dir/several/levels/deep/": "dir 0755", @@ -204,48 +204,48 @@ var extractTests = []extractTest{{ pkgdata: testutil.PackageData["test-package"], options: deb.ExtractOptions{ Extract: map[string][]deb.ExtractInfo{ - "/missing_file": []deb.ExtractInfo{{ - Path: "/missing_file", + "/missing-file": []deb.ExtractInfo{{ + Path: "/missing-file", }}, }, }, - error: `cannot extract from package "test-package": no content at /missing_file`, + error: `cannot extract from package "test-package": no content at /missing-file`, }, { summary: "Missing directory", pkgdata: testutil.PackageData["test-package"], options: deb.ExtractOptions{ Extract: map[string][]deb.ExtractInfo{ - "/missing_dir/": []deb.ExtractInfo{{ - Path: "/missing_dir/", + "/missing-dir/": []deb.ExtractInfo{{ + Path: "/missing-dir/", }}, }, }, - error: `cannot extract from package "test-package": no content at /missing_dir/`, + error: `cannot extract from package "test-package": no content at /missing-dir/`, }, { summary: "Missing glob", pkgdata: testutil.PackageData["test-package"], options: deb.ExtractOptions{ Extract: map[string][]deb.ExtractInfo{ - "/missing_dir/**": []deb.ExtractInfo{{ - Path: "/missing_dir/**", + "/missing-dir/**": []deb.ExtractInfo{{ + Path: "/missing-dir/**", }}, }, }, - error: `cannot extract from package "test-package": no content at /missing_dir/\*\*`, + error: `cannot extract from package "test-package": no content at /missing-dir/\*\*`, }, { summary: "Missing multiple entries", pkgdata: testutil.PackageData["test-package"], options: deb.ExtractOptions{ Extract: map[string][]deb.ExtractInfo{ - "/missing_file": []deb.ExtractInfo{{ - Path: "missing_file", + "/missing-file": []deb.ExtractInfo{{ + Path: "missing-file", }}, - "/missing_dir/": []deb.ExtractInfo{{ - Path: "/missing_dir/", + "/missing-dir/": []deb.ExtractInfo{{ + Path: "/missing-dir/", }}, }, }, - error: `cannot extract from package "test-package": no content at:\n- /missing_dir/\n- /missing_file`, + error: `cannot extract from package "test-package": no content at:\n- /missing-dir/\n- /missing-file`, }, { summary: "Optional entries may be missing", pkgdata: testutil.PackageData["test-package"], @@ -255,34 +255,34 @@ var extractTests = []extractTest{{ Path: "/dir/", }}, "/dir/optional": []deb.ExtractInfo{{ - Path: "/other_dir/foo", + Path: "/other-dir/foo", Optional: true, }}, - "/optional_dir/": []deb.ExtractInfo{{ - Path: "/foo/optional_dir/", + "/optional-dir/": []deb.ExtractInfo{{ + Path: "/foo/optional-dir/", Optional: true, }}, }, }, result: map[string]string{ "/dir/": "dir 0755", - "/other_dir/": "dir 0755", + "/other-dir/": "dir 0755", }, }, { summary: "Optional entries mixed in cannot be missing", pkgdata: testutil.PackageData["test-package"], options: deb.ExtractOptions{ Extract: map[string][]deb.ExtractInfo{ - "/dir/missing_file": []deb.ExtractInfo{{ + "/dir/missing-file": []deb.ExtractInfo{{ Path: "/dir/optional", Optional: true, }, { - Path: "/dir/not_optional", + Path: "/dir/not-optional", Optional: false, }}, }, }, - error: `cannot extract from package "test-package": no content at /dir/missing_file`, + error: `cannot extract from package "test-package": no content at /dir/missing-file`, }} func (s *S) TestExtract(c *C) { diff --git a/internal/slicer/slicer_test.go b/internal/slicer/slicer_test.go index 353247ff..3d3125bc 100644 --- a/internal/slicer/slicer_test.go +++ b/internal/slicer/slicer_test.go @@ -73,21 +73,21 @@ var slicerTests = []slicerTest{{ myslice: contents: /dir/file: - /dir/file_copy: {copy: /dir/file} - /other_dir/file: {symlink: ../dir/file} - /dir/text_file: {text: data1} + /dir/file-copy: {copy: /dir/file} + /other-dir/file: {symlink: ../dir/file} + /dir/text-file: {text: data1} /dir/foo/bar/: {make: true, mode: 01777} `, }, result: map[string]string{ "/dir/": "dir 0755", "/dir/file": "file 0644 cc55e2ec", - "/dir/file_copy": "file 0644 cc55e2ec", + "/dir/file-copy": "file 0644 cc55e2ec", "/dir/foo/": "dir 0755", "/dir/foo/bar/": "dir 01777", - "/dir/text_file": "file 0644 5b41362b", - "/other_dir/": "dir 0755", - "/other_dir/file": "symlink ../dir/file", + "/dir/text-file": "file 0644 5b41362b", + "/other-dir/": "dir 0755", + "/other-dir/file": "symlink ../dir/file", }, }, { summary: "Glob extraction", @@ -98,14 +98,14 @@ var slicerTests = []slicerTest{{ slices: myslice: contents: - /**/other_f*e: + /**/other-f*e: `, }, result: map[string]string{ "/dir/": "dir 0755", "/dir/nested/": "dir 0755", - "/dir/nested/other_file": "file 0644 6b86b273", - "/dir/other_file": "file 0644 63d5dd49", + "/dir/nested/other-file": "file 0644 6b86b273", + "/dir/other-file": "file 0644 63d5dd49", }, }, { summary: "Create new file under extracted directory and preserve parent directory permissions", @@ -169,21 +169,21 @@ var slicerTests = []slicerTest{{ slices: myslice: contents: - /dir/text_file_1: {text: data1, arch: amd64} - /dir/text_file_2: {text: data1, arch: i386} - /dir/text_file_3: {text: data1, arch: [i386, amd64]} - /dir/nested/copy_1: {copy: /dir/nested/file, arch: amd64} - /dir/nested/copy_2: {copy: /dir/nested/file, arch: i386} - /dir/nested/copy_3: {copy: /dir/nested/file, arch: [i386, amd64]} + /dir/text-file-1: {text: data1, arch: amd64} + /dir/text-file-2: {text: data1, arch: i386} + /dir/text-file-3: {text: data1, arch: [i386, amd64]} + /dir/nested/copy-1: {copy: /dir/nested/file, arch: amd64} + /dir/nested/copy-2: {copy: /dir/nested/file, arch: i386} + /dir/nested/copy-3: {copy: /dir/nested/file, arch: [i386, amd64]} `, }, result: map[string]string{ "/dir/": "dir 0755", - "/dir/text_file_1": "file 0644 5b41362b", - "/dir/text_file_3": "file 0644 5b41362b", + "/dir/text-file-1": "file 0644 5b41362b", + "/dir/text-file-3": "file 0644 5b41362b", "/dir/nested/": "dir 0755", - "/dir/nested/copy_1": "file 0644 84237a05", - "/dir/nested/copy_3": "file 0644 84237a05", + "/dir/nested/copy-1": "file 0644 84237a05", + "/dir/nested/copy-3": "file 0644 84237a05", }, }, { summary: "Script: write a file", @@ -194,14 +194,14 @@ var slicerTests = []slicerTest{{ slices: myslice: contents: - /dir/text_file: {text: data1, mutable: true} + /dir/text-file: {text: data1, mutable: true} mutate: | - content.write("/dir/text_file", "data2") + content.write("/dir/text-file", "data2") `, }, result: map[string]string{ "/dir/": "dir 0755", - "/dir/text_file": "file 0644 d98cf53e", + "/dir/text-file": "file 0644 d98cf53e", }, }, { summary: "Script: read a file", @@ -212,18 +212,18 @@ var slicerTests = []slicerTest{{ slices: myslice: contents: - /dir/text_file_1: {text: data1} - /foo/text_file_2: {text: data2, mutable: true} + /dir/text-file-1: {text: data1} + /foo/text-file-2: {text: data2, mutable: true} mutate: | - data = content.read("/dir/text_file_1") - content.write("/foo/text_file_2", data) + data = content.read("/dir/text-file-1") + content.write("/foo/text-file-2", data) `, }, result: map[string]string{ "/dir/": "dir 0755", - "/dir/text_file_1": "file 0644 5b41362b", + "/dir/text-file-1": "file 0644 5b41362b", "/foo/": "dir 0755", - "/foo/text_file_2": "file 0644 5b41362b", + "/foo/text-file-2": "file 0644 5b41362b", }, }, { summary: "Script: use 'until' to remove file after mutate", @@ -234,17 +234,17 @@ var slicerTests = []slicerTest{{ slices: myslice: contents: - /dir/text_file_1: {text: data1, until: mutate} - /foo/text_file_2: {text: data2, mutable: true} + /dir/text-file-1: {text: data1, until: mutate} + /foo/text-file-2: {text: data2, mutable: true} mutate: | - data = content.read("/dir/text_file_1") - content.write("/foo/text_file_2", data) + data = content.read("/dir/text-file-1") + content.write("/foo/text-file-2", data) `, }, result: map[string]string{ "/dir/": "dir 0755", "/foo/": "dir 0755", - "/foo/text_file_2": "file 0644 5b41362b", + "/foo/text-file-2": "file 0644 5b41362b", }, }, { summary: "Script: use 'until' to remove wildcard after mutate", @@ -256,12 +256,12 @@ var slicerTests = []slicerTest{{ myslice: contents: /dir/nested**: {until: mutate} - /other_dir/text_file: {until: mutate, text: data1} + /other-dir/text-file: {until: mutate, text: data1} `, }, result: map[string]string{ "/dir/": "dir 0755", - "/other_dir/": "dir 0755", + "/other-dir/": "dir 0755", }, }, { summary: "Script: 'until' does not remove non-empty directories", @@ -273,13 +273,13 @@ var slicerTests = []slicerTest{{ myslice: contents: /dir/nested/: {until: mutate} - /dir/nested/file_copy: {copy: /dir/file} + /dir/nested/file-copy: {copy: /dir/file} `, }, result: map[string]string{ "/dir/": "dir 0755", "/dir/nested/": "dir 0755", - "/dir/nested/file_copy": "file 0644 cc55e2ec", + "/dir/nested/file-copy": "file 0644 cc55e2ec", }, }, { summary: "Script: cannot write non-mutable files", @@ -290,12 +290,12 @@ var slicerTests = []slicerTest{{ slices: myslice: contents: - /dir/text_file: {text: data1} + /dir/text-file: {text: data1} mutate: | - content.write("/dir/text_file", "data2") + content.write("/dir/text-file", "data2") `, }, - error: `slice test-package_myslice: cannot write file which is not mutable: /dir/text_file`, + error: `slice test-package_myslice: cannot write file which is not mutable: /dir/text-file`, }, { summary: "Script: cannot read unlisted content", slices: []setup.SliceKey{{"test-package", "myslice2"}}, @@ -305,13 +305,13 @@ var slicerTests = []slicerTest{{ slices: myslice1: contents: - /dir/text_file: {text: data1} + /dir/text-file: {text: data1} myslice2: mutate: | - content.read("/dir/text_file") + content.read("/dir/text-file") `, }, - error: `slice test-package_myslice2: cannot read file which is not selected: /dir/text_file`, + error: `slice test-package_myslice2: cannot read file which is not selected: /dir/text-file`, }, { summary: "Script: can read globbed content", slices: []setup.SliceKey{{"test-package", "myslice1"}, {"test-package", "myslice2"}}, @@ -336,9 +336,9 @@ var slicerTests = []slicerTest{{ slices: myslice: contents: - /dir/text_file: {text: data1} + /dir/text-file: {text: data1} mutate: | - content.read("/dir/text_file") + content.read("/dir/text-file") `, }, hackopt: func(c *C, opts *slicer.RunOptions) { @@ -421,10 +421,10 @@ var slicerTests = []slicerTest{{ contents: /**/nested/f?le: mutate: | - content.list("/other_dir") + content.list("/other-dir") `, }, - error: `slice test-package_myslice: cannot list directory which is not selected: /other_dir/`, + error: `slice test-package_myslice: cannot list directory which is not selected: /other-dir/`, }, { summary: "Duplicate copyright symlink is ignored", slices: []setup.SliceKey{{"copyright-symlink-openssl", "bins"}}, diff --git a/internal/testutil/pkgdata.go b/internal/testutil/pkgdata.go index 71e66fbf..46a64ffc 100644 --- a/internal/testutil/pkgdata.go +++ b/internal/testutil/pkgdata.go @@ -16,13 +16,13 @@ var testPackageEntries = []TarEntry{ Dir(0755, "./"), Dir(0755, "./dir/"), Reg(0644, "./dir/file", "12u3q0wej ajsd"), - Reg(0644, "./dir/other_file", "kasjdf0"), + Reg(0644, "./dir/other-file", "kasjdf0"), Dir(0755, "./dir/nested/"), Reg(0644, "./dir/nested/file", "0jqei"), - Reg(0644, "./dir/nested/other_file", "1"), + Reg(0644, "./dir/nested/other-file", "1"), Dir(0755, "./dir/several/levels/deep/"), Reg(0644, "./dir/several/levels/deep/file", "129i381 "), - Dir(0755, "./other_dir/"), + Dir(0755, "./other-dir/"), Dir(01777, "./parent/"), Dir(0764, "./parent/permissions/"), Reg(0755, "./parent/permissions/file", "ajse0"),