Skip to content

Commit

Permalink
Chore: remove darwin code on test because orbstack can run it
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreamacro committed Aug 26, 2023
1 parent 45c10a1 commit e4cd3e5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 102 deletions.
22 changes: 7 additions & 15 deletions test/clash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
"fmt"
"io"
"net"
"net/netip"
"os"
"path/filepath"
"runtime"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -39,7 +39,7 @@ const (

var (
waitTime = time.Second
localIP = net.ParseIP("127.0.0.1")
localIP = netip.MustParseAddr("127.0.0.1")

defaultExposedPorts = nat.PortSet{
"10002/tcp": struct{}{},
Expand All @@ -53,7 +53,6 @@ var (
{HostPort: "10002", HostIP: "0.0.0.0"},
},
}
isDarwin = runtime.GOOS == "darwin"
)

func init() {
Expand All @@ -64,13 +63,6 @@ func init() {
homeDir := filepath.Join(currentDir, "config")
C.SetHomeDir(homeDir)

if isDarwin {
localIP, err = defaultRouteIP()
if err != nil {
panic(err)
}
}

c, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
panic(err)
Expand Down Expand Up @@ -302,7 +294,7 @@ func testPingPongWithPacketConn(t *testing.T, pc net.PacketConn) error {
require.NoError(t, err)
defer l.Close()

rAddr := &net.UDPAddr{IP: localIP, Port: 10001}
rAddr := &net.UDPAddr{IP: localIP.AsSlice(), Port: 10001}

pingCh, pongCh, test := newPingPongPair()
go func() {
Expand Down Expand Up @@ -437,7 +429,7 @@ func testLargeDataWithPacketConn(t *testing.T, pc net.PacketConn) error {
require.NoError(t, err)
defer l.Close()

rAddr := &net.UDPAddr{IP: localIP, Port: 10001}
rAddr := &net.UDPAddr{IP: localIP.AsSlice(), Port: 10001}

times := 50
chunkSize := int64(1024)
Expand Down Expand Up @@ -570,7 +562,7 @@ func testSuit(t *testing.T, proxy C.ProxyAdapter) {

pc, err := proxy.ListenPacketContext(context.Background(), &C.Metadata{
NetWork: C.UDP,
DstIP: localIP,
DstIP: localIP.AsSlice(),
DstPort: 10001,
})
require.NoError(t, err)
Expand All @@ -580,7 +572,7 @@ func testSuit(t *testing.T, proxy C.ProxyAdapter) {

pc, err = proxy.ListenPacketContext(context.Background(), &C.Metadata{
NetWork: C.UDP,
DstIP: localIP,
DstIP: localIP.AsSlice(),
DstPort: 10001,
})
require.NoError(t, err)
Expand All @@ -590,7 +582,7 @@ func testSuit(t *testing.T, proxy C.ProxyAdapter) {

pc, err = proxy.ListenPacketContext(context.Background(), &C.Metadata{
NetWork: C.UDP,
DstIP: localIP,
DstIP: localIP.AsSlice(),
DstPort: 10001,
})
require.NoError(t, err)
Expand Down
5 changes: 1 addition & 4 deletions test/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ func startContainer(cfg *container.Config, hostCfg *container.HostConfig, name s
}
defer c.Close()

if !isDarwin {
hostCfg.NetworkMode = "host"
}

hostCfg.NetworkMode = "host"
container, err := c.ContainerCreate(context.Background(), cfg, hostCfg, nil, nil, name)
if err != nil {
return "", err
Expand Down
2 changes: 1 addition & 1 deletion test/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ require (
github.com/miekg/dns v1.1.55
github.com/stretchr/testify v1.8.4
go.uber.org/automaxprocs v1.5.3
golang.org/x/net v0.14.0
)

replace github.com/Dreamacro/clash => ../
Expand Down Expand Up @@ -48,6 +47,7 @@ require (
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/sync v0.3.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
Expand Down
70 changes: 0 additions & 70 deletions test/util_darwin_test.go

This file was deleted.

12 changes: 0 additions & 12 deletions test/util_other_test.go

This file was deleted.

0 comments on commit e4cd3e5

Please sign in to comment.