From d49a11e5838a39afe2dbd0e3af81f949e710b685 Mon Sep 17 00:00:00 2001 From: Softonik Date: Sat, 29 Jun 2024 01:14:35 +0300 Subject: [PATCH] =?UTF-8?q?Magefile=20=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Magefile.go | 179 ++++++++-------------------------------------------- 1 file changed, 28 insertions(+), 151 deletions(-) diff --git a/Magefile.go b/Magefile.go index 1dd8bcef..c6fa1afe 100644 --- a/Magefile.go +++ b/Magefile.go @@ -3,15 +3,8 @@ package main import ( - "context" - "log" - "os" - "strings" - // mage:import . "magefile/docker" - - "github.com/magefile/mage/mg" ) var ( @@ -29,152 +22,11 @@ func init() { } func Test() { - mg.Deps(TestLibs) - mg.Deps(TestIntegration) } -func TestLibs(ctx context.Context) error { - paths := []string{ - "pkg", - "pkg/printer", - "pkg/scenarios", - "pkg/link", - "pkg/link/wifi", - "pkg/parser", - "internal", - } - - listTests(paths) - - // err := addTest("test") - // if err != nil { - // println("ERROR: " + "test") - // return err - // } - - return runListedTests() -} -func TestIntegration(ctx context.Context) error { - return runTests("./test/int") -} -func TestSystem(ctx context.Context) error { - return runTests("./test") -} - -func listTests(paths []string) error { - for _, p := range paths { - listAndTest(p) - } - - return nil -} - -func listAndTest(p string) error { - entries, err := os.ReadDir(p) - if err != nil { - log.Fatal(err) - } - - return testList(p, entries) -} - -func testList(p string, entries []os.DirEntry) error { - for _, e := range entries { - testOne(p, e) - } - - return nil -} - -func testOne(p string, e os.DirEntry) error { - if !e.IsDir() { - return nil - } - if e.Name() == "driver" { - return nil - } - if e.Name() == "lib" { - return nil - } - if e.Name() == "testlib" { - return nil - } - - entries, err := os.ReadDir(p + "/" + e.Name()) - if err != nil { - log.Fatal(err) - } - - found := false - for _, e2 := range entries { - if e2.IsDir() { - continue - } - - if strings.Contains(e2.Name(), "_test.go") { - found = true - break - } - } - if !found { - return nil - } - - testPath := p + "/" + e.Name() - err = addTest(testPath) - if err != nil { - println("ERROR: " + testPath) - return err - } - - return nil -} - -func addTest(p string) error { - tests_to_run = append(tests_to_run, "./"+p) - return nil -} - -func runListedTests() error { - test_paths := strings.Join(tests_to_run, " ") - return runTests(test_paths) -} - -func runTests(paths string) error { - Bash(`cp -f $HOME/.Xauthority /tmp/._test_Xauthority`) - return Bash(`sudo docker run -ti --rm \ - -h host \ - --net=none \ - -v /etc/localtime:/etc/localtime:ro \ - -v ` + GolangVolume + `:/usr/local/go:ro \ - \ - -v /gopath:/gopath:rw \ - -v ${PWD}:/app \ - -v /usr/bin/docker:/usr/bin/docker:ro \ - -v /var/run/docker.sock:/var/run/docker.sock:ro \ - -v /usr/bin/socat:/usr/bin/socat \ - \ - -e GOPATH=/gopath \ - -e GOCACHE=/gopath/gocache \ - -e APPDIR=${PWD} \ - \ - --device=/dev/dri/card0 \ - -e DISPLAY=:0 \ - -v /tmp/.X11-unix:/tmp/.X11-unix:ro \ - -v /tmp/._test_Xauthority:/home/user/.Xauthority:ro \ - \ - -w /app \ - -u 0 \ - \ - --entrypoint=/bin/bash \ - \ - ` + ImageName + " -c '" + ` \ - for t in ` + paths + `; do \ - go test -v -p 1 -gcflags=-l -count=1 $t || exit 1; \ - done'`) -} - -func build() { +func build() error { BuildAllWithSync() + + return nil } func BuildAllWithSync() { @@ -241,6 +93,31 @@ func BuildLLVMInDocker() { make llvm-build '`) } +func Tinygo() { + LLVMBuildImageName := "my/qtbase.dev" + Bash(`sudo docker run --rm \ + -h host \ + --net=bridge \ + -v /etc/localtime:/etc/localtime:ro \ + -v ` + GolangVolume + `:/usr/local/go:ro \ + -e PATH=$PATH:/usr/local/go/bin \ + \ + -v /gopath:/gopath:rw \ + -e GOPATH=/gopath \ + -e GOCACHE=/gopath/gocache \ + ` + DockerProxyOptions + ` \ + \ + -v ${PWD}:/app \ + \ + -w /app \ + -u 1000 \ + \ + --entrypoint=/app/build/tinygo \ + \ + ` + LLVMBuildImageName + " " + ` \ + targets \ + `) +} func LLVMSource() error { return Bash(`make llvm-source`) }