fix(build): ensure tests work.

This commit is contained in:
Alexandre Pujol 2024-03-27 16:26:01 +00:00
parent b88b8b8c26
commit cf7ce9603e
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
7 changed files with 17 additions and 7 deletions

View file

@ -9,11 +9,18 @@ import (
"os/exec"
"testing"
"github.com/arduino/go-paths-helper"
"github.com/roddhjav/apparmor.d/pkg/prebuild/builder"
"github.com/roddhjav/apparmor.d/pkg/prebuild/cfg"
"github.com/roddhjav/apparmor.d/pkg/prebuild/prepare"
)
func setTestBuildDirectories(name string) {
testRoot := paths.New("/tmp/tests")
cfg.Root = testRoot.Join(name)
cfg.RootApparmord = cfg.Root.Join("apparmor.d")
}
func chdirGitRoot() {
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
out, err := cmd.Output()
@ -71,6 +78,7 @@ func Test_PreBuild(t *testing.T) {
chdirGitRoot()
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
setTestBuildDirectories(tt.name)
cfg.Distribution = tt.dist
if tt.full {
prepare.Register("fsp")