mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
Some checks are pending
CodeQL / codeql (push) Waiting to run
Docker Check / lint (push) Waiting to run
Docker Check / build (push) Waiting to run
Gateway Conformance / gateway-conformance (push) Waiting to run
Gateway Conformance / gateway-conformance-libp2p-experiment (push) Waiting to run
Go Build / go-build (push) Waiting to run
Go Check / go-check (push) Waiting to run
Go Lint / go-lint (push) Waiting to run
Go Test / go-test (push) Waiting to run
Interop / interop-prep (push) Waiting to run
Interop / helia-interop (push) Blocked by required conditions
Interop / ipfs-webui (push) Blocked by required conditions
Sharness / sharness-test (push) Waiting to run
Spell Check / spellcheck (push) Waiting to run
* ci: optimize build workflows - use go version from go.mod instead of hardcoding - group platforms by OS for parallel builds - remove legacy try-build targets * fix: checkout before setup-go in all workflows setup-go needs go.mod to be present, so checkout must happen first * chore: remove deprecated // +build syntax go 1.17+ uses //go:build, the old syntax is no longer needed * simplify: remove nofuse tag from CI workflows - workflows now rely on platform build constraints - keep make nofuse target for manual builds - remove unused appveyor.yml * ci: remove legacy travis variable and fix gateway-conformance - remove TRAVIS env variable from 4 workflows - fix gateway-conformance checkout path to match working-directory - replace deprecated cache-go-action with built-in setup-go caching
84 lines
1.4 KiB
Go
84 lines
1.4 KiB
Go
//go:build testrunmain
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
"os/exec"
|
|
"os/signal"
|
|
"strconv"
|
|
"syscall"
|
|
)
|
|
|
|
func main() {
|
|
coverDir := os.Getenv("IPFS_COVER_DIR")
|
|
if len(coverDir) == 0 {
|
|
fmt.Println("IPFS_COVER_DIR not defined")
|
|
os.Exit(1)
|
|
}
|
|
coverFile, err := os.CreateTemp(coverDir, "coverage-")
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
os.Exit(1)
|
|
}
|
|
|
|
retFile, err := os.CreateTemp("", "cover-ret-file")
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
os.Exit(1)
|
|
}
|
|
|
|
args := []string{"-test.run", "^TestRunMain$", "-test.coverprofile=" + coverFile.Name(), "--"}
|
|
args = append(args, os.Args[1:]...)
|
|
|
|
p := exec.Command("ipfs-test-cover", args...)
|
|
p.Stdin = os.Stdin
|
|
p.Stdout = os.Stdout
|
|
p.Stderr = os.Stderr
|
|
p.Env = append(os.Environ(), "IPFS_COVER_RET_FILE="+retFile.Name())
|
|
|
|
p.SysProcAttr = &syscall.SysProcAttr{
|
|
Pdeathsig: syscall.SIGTERM,
|
|
}
|
|
|
|
sig := make(chan os.Signal, 10)
|
|
start := make(chan struct{})
|
|
go func() {
|
|
<-start
|
|
for {
|
|
p.Process.Signal(<-sig)
|
|
}
|
|
}()
|
|
|
|
signal.Notify(sig, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
|
|
|
|
err = p.Start()
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
os.Exit(1)
|
|
}
|
|
|
|
close(start)
|
|
|
|
err = p.Wait()
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
os.Exit(1)
|
|
}
|
|
|
|
b, err := io.ReadAll(retFile)
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
os.Exit(1)
|
|
}
|
|
b = b[:len(b)-1]
|
|
d, err := strconv.Atoi(string(b))
|
|
if err != nil {
|
|
fmt.Println(err.Error())
|
|
os.Exit(1)
|
|
}
|
|
os.Exit(d)
|
|
}
|