docs & feat: add license & attribution notice (Apache-2.0 / GPL-3.0) and core system enhancements
This commit is contained in:
1 parent
507836d367
commit
ce6aabfc55
47 files changed
+5674
-724
No files matched your search
@@ -0,0 +1,49 @@
|
||||
// Package testutil provides isolated runtime fixtures for tests that write saves.
|
||||
package testutil
|
||||
|
||||
import (
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CopyRuntime copies data, never links writable saves to the source checkout.
|
||||
// Local operator configuration and binaries are intentionally excluded.
|
||||
func CopyRuntime(root, destination string) error {
|
||||
entries, err := os.ReadDir(root)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, entry := range entries {
|
||||
name := entry.Name()
|
||||
if entry.IsDir() || strings.HasSuffix(name, ".local.json") || !(strings.HasSuffix(name, ".json") || name == "persistent" || name == "go.mod") {
|
||||
continue
|
||||
}
|
||||
data, err := os.ReadFile(filepath.Join(root, name))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = os.WriteFile(filepath.Join(destination, name), data, 0600); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return filepath.WalkDir(filepath.Join(root, "resources"), func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
relative, err := filepath.Rel(root, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
target := filepath.Join(destination, relative)
|
||||
if d.IsDir() {
|
||||
return os.MkdirAll(target, 0700)
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(target, data, 0600)
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user