Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge testutil/pkgdata-* branches and resolve conflicts #84

Closed
wants to merge 4 commits into from

Conversation

woky
Copy link
Contributor

@woky woky commented Jun 21, 2023

Merge and fix conflicts in unrelated changes to testutil.pkgdata.

@woky
Copy link
Contributor Author

woky commented Jun 21, 2023

This PR depends on #85, #87 and #86

@woky woky added the Blocked Waiting for something external label Jun 21, 2023
woky added 4 commits June 22, 2023 12:29
MakeDeb() now expects that all provided tar entries have a non-empty
name. Otherwise it panics on array out of bounds access. Fix it.

We can create tarballs containing entries with empty name just fine. It
makes GNU tar fail when extracting, but it fails gracefully with

  tar: Substituting `.' for empty member name
  -rw-r--r-- root/root         0 1970-01-01 01:00
  tar: .: Cannot open: File exists
  tar: Exiting with failure status due to previous errors
Add MakeTestDeb() function to testutil/pkgdata. This function is just
like MakeDeb() except that it doesn't return an error. Instead, it
panics on errors.

This is useful in tests where package data is created in top-level test
case structures where we don't need to handle the error, e.g.:

	var testCases = []TestCase{{
		pkg: MakeTestDeb([]TarEntry{
			...
		}),
	}, {
		...
	}}
Introduce shorthand constructors for testutil.TarEntry structures. These
are REG(), DIR() and LNK() functions.

The rationale for this addition is to make the test case definition less
verbose. There are other changes in the queue that construct custom
packages to test various test cases. In all these new tests (and old
ones as well) we only care about file's type, path, mode and content.
With these shorthand constructors and function aliases we can define tar
entries like:

	DIR(0755, "./data/"),
	REG(0600, "./data/document.txt", "words words words"),
	LNK(0777, "./data/document", "document.txt"),

Instead of:

	testutil.TarEntry{
		Header: tar.Header{
			Name: "./data/",
			Mode: 0755,
		},
	},
	testutil.TarEntry{
		Header: tar.Header{
			Name: "./document.txt",
			Mode: 0600,
		},
		Content: []byte("words words words"),
	},
	testutil.TarEntry{
		Header: tar.Header{
			Name:     "./document.txt",
			Mode:     0777,
			Linkname: "document.txt",
		},
	},

The reason for the 3 letter names and the order of arguments is to make
the list of paths aligned on the same column in tarball definitions.

These function only create barebone TarEntry. It'll still get adjusted
when passed through fixupTarEntry().
…ata-test-deb' and 'pub/testutil-pkgdata-shorthands' into pub/testutil-pkgdata
@woky woky force-pushed the pub/testutil-pkgdata branch from 4ca61c1 to 95c51be Compare June 22, 2023 10:38
@woky woky changed the title Merge branches 'pub/testutil-pkgdata-empty-names', 'pub/testutil-pkgdata-test-deb' and 'pub/testutil-pkgdata-shorthands' into pub/testutil-pkgdata Merge testutil/pkgdata-* branches and resolve conflicts Jun 22, 2023
@woky
Copy link
Contributor Author

woky commented Aug 30, 2023

This merge is not required anymore.

@woky woky closed this Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked Waiting for something external
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants