internal/pkg: temporary scratch space for cure
All checks were successful
Test / Create distribution (push) Successful in 43s
Test / Sandbox (push) Successful in 2m30s
Test / ShareFS (push) Successful in 3m40s
Test / Hpkg (push) Successful in 4m21s
Test / Sandbox (race detector) (push) Successful in 5m4s
Test / Hakurei (race detector) (push) Successful in 5m52s
Test / Hakurei (push) Successful in 2m35s
Test / Flake checks (push) Successful in 1m52s
All checks were successful
Test / Create distribution (push) Successful in 43s
Test / Sandbox (push) Successful in 2m30s
Test / ShareFS (push) Successful in 3m40s
Test / Hpkg (push) Successful in 4m21s
Test / Sandbox (race detector) (push) Successful in 5m4s
Test / Hakurei (race detector) (push) Successful in 5m52s
Test / Hakurei (push) Successful in 2m35s
Test / Flake checks (push) Successful in 1m52s
This allows for more flexibility during implementation. The use case that required this was for expanding single directory tarballs. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -72,7 +72,7 @@ type stubArtifact struct {
|
||||
params []byte
|
||||
deps []pkg.Artifact
|
||||
|
||||
cure func(work *check.Absolute, loadData pkg.CacheDataFunc) error
|
||||
cure func(work, temp *check.Absolute, loadData pkg.CacheDataFunc) error
|
||||
}
|
||||
|
||||
func (a stubArtifact) Kind() pkg.Kind { return a.kind }
|
||||
@@ -80,10 +80,10 @@ func (a stubArtifact) Params() []byte { return a.params }
|
||||
func (a stubArtifact) Dependencies() []pkg.Artifact { return a.deps }
|
||||
|
||||
func (a stubArtifact) Cure(
|
||||
work *check.Absolute,
|
||||
work, temp *check.Absolute,
|
||||
loadData pkg.CacheDataFunc,
|
||||
) error {
|
||||
return a.cure(work, loadData)
|
||||
return a.cure(work, temp, loadData)
|
||||
}
|
||||
|
||||
// A stubFile implements [File] with hardcoded behaviour.
|
||||
@@ -108,7 +108,7 @@ func newStubFile(
|
||||
kind,
|
||||
nil,
|
||||
nil,
|
||||
func(work *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
func(*check.Absolute, *check.Absolute, pkg.CacheDataFunc) error {
|
||||
panic("unreachable")
|
||||
},
|
||||
}}}
|
||||
@@ -375,7 +375,7 @@ func TestCache(t *testing.T) {
|
||||
binary.LittleEndian.AppendUint64(nil, pkg.TarGzip),
|
||||
overrideIdent{testdataChecksum, stubArtifact{}},
|
||||
)
|
||||
makeSample := func(work *check.Absolute, _ pkg.CacheDataFunc) error {
|
||||
makeSample := func(work, _ *check.Absolute, _ pkg.CacheDataFunc) error {
|
||||
if err := os.Mkdir(work.String(), 0700); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -476,14 +476,14 @@ func TestCache(t *testing.T) {
|
||||
|
||||
{"cure fault", overrideIdent{pkg.ID{0xff, 0}, stubArtifact{
|
||||
kind: pkg.KindTar,
|
||||
cure: func(work *check.Absolute, _ pkg.CacheDataFunc) error {
|
||||
cure: func(work, _ *check.Absolute, _ pkg.CacheDataFunc) error {
|
||||
return makeGarbage(work, stub.UniqueError(0xcafe))
|
||||
},
|
||||
}}, nil, pkg.Checksum{}, stub.UniqueError(0xcafe)},
|
||||
|
||||
{"checksum mismatch", overrideChecksum{pkg.Checksum{}, overrideIdent{pkg.ID{0xff, 1}, stubArtifact{
|
||||
kind: pkg.KindTar,
|
||||
cure: func(work *check.Absolute, _ pkg.CacheDataFunc) error {
|
||||
cure: func(work, _ *check.Absolute, _ pkg.CacheDataFunc) error {
|
||||
return makeGarbage(work, nil)
|
||||
},
|
||||
}}}, nil, pkg.Checksum{}, &pkg.ChecksumMismatchError{
|
||||
@@ -503,7 +503,7 @@ func TestCache(t *testing.T) {
|
||||
|
||||
{"loadData directory", overrideIdent{pkg.ID{0xff, 3}, stubArtifact{
|
||||
kind: pkg.KindTar,
|
||||
cure: func(work *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
cure: func(work, _ *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
_, err := loadData(overrideChecksumFile{checksum: wantChecksum})
|
||||
return err
|
||||
},
|
||||
@@ -518,21 +518,21 @@ func TestCache(t *testing.T) {
|
||||
|
||||
{"no output", overrideIdent{pkg.ID{0xff, 4}, stubArtifact{
|
||||
kind: pkg.KindTar,
|
||||
cure: func(work *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
cure: func(work, _ *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
return nil
|
||||
},
|
||||
}}, nil, pkg.Checksum{}, pkg.NoOutputError{}},
|
||||
|
||||
{"file output", overrideIdent{pkg.ID{0xff, 5}, stubArtifact{
|
||||
kind: pkg.KindTar,
|
||||
cure: func(work *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
cure: func(work, _ *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
return os.WriteFile(work.String(), []byte{0}, 0400)
|
||||
},
|
||||
}}, nil, pkg.Checksum{}, errors.New("non-file artifact produced regular file")},
|
||||
|
||||
{"symlink output", overrideIdent{pkg.ID{0xff, 6}, stubArtifact{
|
||||
kind: pkg.KindTar,
|
||||
cure: func(work *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
cure: func(work, _ *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
return os.Symlink(work.String(), work.String())
|
||||
},
|
||||
}}, nil, pkg.Checksum{}, pkg.InvalidFileModeError(
|
||||
@@ -549,7 +549,7 @@ func TestCache(t *testing.T) {
|
||||
go func() {
|
||||
if _, _, err := c.Cure(overrideIdent{pkg.ID{0xff}, stubArtifact{
|
||||
kind: pkg.KindTar,
|
||||
cure: func(work *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
cure: func(work, _ *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
close(ready)
|
||||
<-n
|
||||
return wantErr
|
||||
@@ -579,7 +579,7 @@ func TestCache(t *testing.T) {
|
||||
|
||||
{"file output", overrideIdent{pkg.ID{0xff, 2}, stubArtifact{
|
||||
kind: pkg.KindTar,
|
||||
cure: func(work *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
cure: func(work, _ *check.Absolute, loadData pkg.CacheDataFunc) error {
|
||||
return os.WriteFile(work.String(), []byte{0}, 0400)
|
||||
},
|
||||
}}, nil, pkg.Checksum{}, errors.New("non-file artifact produced regular file")},
|
||||
|
||||
Reference in New Issue
Block a user