Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
48af235c2f | ||
|
|
06127e291f |
@@ -13,14 +13,11 @@ The structure of these files can be found
|
||||
schema `mfer/mf.proto` for exact field numbers and types. Both are included in
|
||||
the [project repository](https://git.eeqj.de/sneak/mfer).
|
||||
|
||||
The current version is pre-1.0 and while the repo was published in 2022, there
|
||||
has not yet been any versioned release. [SemVer](https://semver.org) will be
|
||||
used for releases.
|
||||
|
||||
A version is a git tag, and no file in the tree records a version number.
|
||||
`mfer version` prints the revision the build stamped into the binary, which for
|
||||
`make build` and the Docker image is the output of `git describe` on the
|
||||
checkout they build. A binary built without that stamp, as
|
||||
Releases are git tags named by [SemVer](https://semver.org), starting with
|
||||
`v1.0.0`. No file in the tree records a version number. `mfer version` prints
|
||||
the revision the build stamped into the binary, which for `make build` and the
|
||||
Docker image is the output of `git describe` on the checkout they build. A
|
||||
binary built without that stamp, as
|
||||
`go install sneak.berlin/go/mfer/cmd/mfer@<tag>` builds it, prints the module
|
||||
version Go records in it instead. A program that imports the `mfer` package
|
||||
finds the version it was built against in its own build information
|
||||
|
||||
@@ -197,8 +197,8 @@ func countCheckFailures(
|
||||
// manifest, and anything the search cannot read: each is a failure, logged
|
||||
// at error level, under --no-extra-files, otherwise a warning. index.mf at
|
||||
// the top of the base directory is never reported as absent from the
|
||||
// manifest, since gen and fetch write the manifest there, even when check
|
||||
// is given another manifest or a URL.
|
||||
// manifest, even when check is given another manifest or a URL, since gen
|
||||
// and fetch write the manifest there.
|
||||
func findExtraFiles(
|
||||
ctx context.Context, cmd *cli.Command, chk *mfer.Checker, failures *int64,
|
||||
) error {
|
||||
|
||||
@@ -1192,9 +1192,10 @@ func TestCheckURLManifestWithoutTempDirectory(t *testing.T) {
|
||||
|
||||
// TestCheckNeverReportsIndexMfAtTopOfBase checks a tree holding index.mf at
|
||||
// its top, where gen and fetch write the manifest, against a manifest that
|
||||
// does not list it, given by URL and by a path outside the tree: the check
|
||||
// passes under --no-extra-files. index.mf in a subdirectory, and the temp
|
||||
// file fetch saves index.mf through, are still reported.
|
||||
// does not list it, given by URL and by a path outside the tree: check never
|
||||
// reports it, and passes with and without --no-extra-files. index.mf in a
|
||||
// subdirectory, and the temp file fetch saves index.mf through, are still
|
||||
// reported.
|
||||
func TestCheckNeverReportsIndexMfAtTopOfBase(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1220,16 +1221,22 @@ func TestCheckNeverReportsIndexMfAtTopOfBase(t *testing.T) {
|
||||
require.NoError(t, os.WriteFile(
|
||||
filepath.Join(base, defaultManifestName), manifest, 0o600))
|
||||
|
||||
check := func() (int, string) {
|
||||
opts := testOpts([]string{
|
||||
testApp, cmdCheck, testFlagNoExtra, testFlagBase, base, manifestArg,
|
||||
}, afero.NewOsFs())
|
||||
check := func(flags ...string) (int, string) {
|
||||
opts := testOpts(slices.Concat(
|
||||
[]string{testApp, cmdCheck}, flags,
|
||||
[]string{testFlagBase, base, manifestArg},
|
||||
), afero.NewOsFs())
|
||||
|
||||
return runCLI(opts), testStderr(t, opts)
|
||||
}
|
||||
|
||||
exitCode, stderr := check()
|
||||
assert.Equal(t, 0, exitCode, "stderr: %s", stderr)
|
||||
assert.NotContains(t, stderr, "EXTRA: "+defaultManifestName)
|
||||
|
||||
exitCode, stderr = check(testFlagNoExtra)
|
||||
assert.Equal(t, 0, exitCode, "stderr: %s", stderr)
|
||||
assert.NotContains(t, stderr, "EXTRA: "+defaultManifestName)
|
||||
|
||||
reported := []string{
|
||||
testSubdir + "/" + defaultManifestName,
|
||||
@@ -1243,8 +1250,9 @@ func TestCheckNeverReportsIndexMfAtTopOfBase(t *testing.T) {
|
||||
os.WriteFile(filepath.Join(base, path), manifest, 0o600))
|
||||
}
|
||||
|
||||
exitCode, stderr = check()
|
||||
exitCode, stderr = check(testFlagNoExtra)
|
||||
assert.Equal(t, 1, exitCode, "stderr: %s", stderr)
|
||||
assert.NotContains(t, stderr, "EXTRA: "+defaultManifestName)
|
||||
|
||||
for _, path := range reported {
|
||||
assert.Contains(t, stderr, "EXTRA: "+path)
|
||||
@@ -1323,6 +1331,33 @@ func TestCheckWithUnlistableDirectory(t *testing.T) {
|
||||
assert.Contains(t, testStderr(t, opts), "unlisted.txt")
|
||||
}
|
||||
|
||||
// TestCheckReportsUnreadableIndexMfAtTopOfBase has a directory named
|
||||
// index.mf at the top of the base that cannot be listed. check leaves out
|
||||
// only the report that index.mf is not in the manifest, so it reports the
|
||||
// error and fails under --no-extra-files.
|
||||
func TestCheckReportsUnreadableIndexMfAtTopOfBase(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
unreadable := filepath.Join(testDir, defaultManifestName)
|
||||
|
||||
mem := afero.NewMemMapFs()
|
||||
require.NoError(t, mem.MkdirAll(unreadable, 0o755))
|
||||
writeTestFile(t, mem, testFile1, "hello")
|
||||
|
||||
opts := testOpts([]string{
|
||||
testApp, cmdGenerate, "-q", "-o", testManifest, testDir,
|
||||
}, mem)
|
||||
require.Equal(t, 0, runCLI(opts), "stderr: %s", testStderr(t, opts))
|
||||
|
||||
fs := unlistableDirFs{Fs: mem, dir: unreadable}
|
||||
|
||||
opts = testOpts([]string{
|
||||
testApp, cmdCheck, testFlagNoExtra, testFlagBase, testDir, testManifest,
|
||||
}, fs)
|
||||
assert.Equal(t, 1, runCLI(opts), "stderr: %s", testStderr(t, opts))
|
||||
assert.Contains(t, testStderr(t, opts), "ERROR: "+defaultManifestName)
|
||||
}
|
||||
|
||||
func TestGenerateAtomicWriteNoTempFileOnSuccess(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user