mirror of
https://github.com/soypat/lneto.git
synced 2026-09-01 04:19:05 +00:00
fix tinygo build; add tinygo test to test pipeline if available
This commit is contained in:
+13
-3
@@ -104,9 +104,11 @@ func (s StackGo) SocketNetip(ctx context.Context, network string, family, sotype
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
uc := udpconn{
|
uc := udpconn{
|
||||||
Conn: &conn,
|
Conn: &conn,
|
||||||
localAddr: net.UDPAddrFromAddrPort(laddr),
|
// TODO: use udpaddr until UDPAddrFromAddrPort added to tinygo.
|
||||||
raddr: net.UDPAddrFromAddrPort(raddr),
|
// https://github.com/tinygo-org/net/issues/45
|
||||||
|
localAddr: udpaddr(laddr),
|
||||||
|
raddr: udpaddr(raddr),
|
||||||
}
|
}
|
||||||
return uc, nil
|
return uc, nil
|
||||||
case "tcp", "tcp4":
|
case "tcp", "tcp4":
|
||||||
@@ -244,3 +246,11 @@ var _ net.Conn = udpconn{}
|
|||||||
|
|
||||||
func (c udpconn) LocalAddr() net.Addr { return c.localAddr }
|
func (c udpconn) LocalAddr() net.Addr { return c.localAddr }
|
||||||
func (c udpconn) RemoteAddr() net.Addr { return c.raddr }
|
func (c udpconn) RemoteAddr() net.Addr { return c.raddr }
|
||||||
|
|
||||||
|
func udpaddr(addr netip.AddrPort) net.Addr {
|
||||||
|
return &net.UDPAddr{
|
||||||
|
IP: addr.Addr().AsSlice(),
|
||||||
|
Zone: addr.Addr().Zone(),
|
||||||
|
Port: int(addr.Port()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
//go:build !tinygo
|
||||||
|
|
||||||
|
// Exclude tinygo compiler from build since exec package and t.Skip() are unimplemented.
|
||||||
|
// Also: wouldn't including tinygo cause a recursive call to tinygo test?
|
||||||
|
package xnet
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os/exec"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestTinyGoTest(t *testing.T) {
|
||||||
|
if exec.Command("tinygo", "version").Run() != nil {
|
||||||
|
t.Skip("tinygo not installed")
|
||||||
|
}
|
||||||
|
// This takes a long time. Consider running only important
|
||||||
|
// tests with -run=TestXxx flag: `go test ./... -run=TestXxx`
|
||||||
|
out, err := exec.Command("tinygo", "test", ".").CombinedOutput()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("tinygo failed to test:", err, "\n", string(out))
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user