Magefile поправлен
Некоторые проверки провалились
macOS / build-macos (amd64, macos-12) (push) Has been cancelled
macOS / build-macos (arm64, macos-14) (push) Has been cancelled
macOS / homebrew-install (16) (push) Has been cancelled
macOS / homebrew-install (17) (push) Has been cancelled
Docker / build-push-dev (push) Has been cancelled
Linux / build-linux (push) Has been cancelled
Linux / assert-test-linux (push) Has been cancelled
Nix / nix-test (push) Has been cancelled
Windows / build-windows (push) Has been cancelled
Linux / test-linux-build (push) Has been cancelled
Linux / build-linux-cross (arm, armhf, arm-linux-gnueabihf) (push) Has been cancelled
Linux / build-linux-cross (arm64, arm64, aarch64-linux-gnu) (push) Has been cancelled
Windows / smoke-test-windows (push) Has been cancelled
Windows / stdlib-test-windows (push) Has been cancelled
Windows / stdlib-wasi-test-windows (push) Has been cancelled

Этот коммит содержится в:
Softonik 2024-06-29 01:14:35 +03:00
родитель 5cc0ba40b6
коммит d49a11e583

Просмотреть файл

@ -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`)
}