doujiunai2169 2019-02-25 18:37
浏览 34
已采纳

Travis构建用于定位Wasm

I'm building a go module targeting Wasm that I need to test.

Current configuration

The travis.yml config:

language: go
go:
  - 1.11.x
before_install:
  - curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
  - dep ensure

And the following makefile:

all: deps test 
deps:
    GOOS=js GOARCH=wasm go get ./...
test: 
    GOOS=js GOARCH=wasm go test ./...
test-cover:
    $(GOPATH)/bin/mockgen -source=dom/dom.go -destination=mock/dom.go -package=mock
    $(GOPATH)/bin/mockgen -source=vnode.go -destination=mock/node.go -package=mock
    GOOS=js GOARCH=wasm go test ./... -coverprofile=cover.out
    go tool cover -html=cover.out

And my go env:

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/marvinfrachet/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/marvinfrachet/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/t0/7bv6yclx1d913wtl6rdsvjtr0000gn/T/go-build435765871=/tmp/go-build -gno-record-gcc-switches -fno-common"

The problem

On my build, I'm having the following error:

GOOS=js GOARCH=wasm go get ./...
GOOS=js GOARCH=wasm go test ./...
fork/exec /tmp/go-build540008292/b001/go-vdom-wasm.test: exec format error
FAIL    github.com/mfrachet/go-vdom-wasm    0.004s
?       github.com/mfrachet/go-vdom-wasm/dom    [no test files]
fork/exec /tmp/go-build540008292/b118/helpers.test: exec format error
FAIL    github.com/mfrachet/go-vdom-wasm/helpers    0.005s
?       github.com/mfrachet/go-vdom-wasm/mock   [no test files]

https://travis-ci.org/mfrachet/go-vdom-wasm

On a locale machine, it's working great and my tests all pass.

I think the problem is due to the GOOS=js that doesn't seem to be understood.

  • 写回答

1条回答 默认 最新

  • dqly83915 2019-02-28 06:33
    关注

    It might be that you are missing go_js_wasm_exec in your $PATH, which is required when launching go test with GOOS=js GOARCH=wasm.

    It is located in the misc/wasm directory of the go SDK so this could fix your travis build:

    export PATH="$PATH:$(go env GOROOT)/misc/wasm"
    

    Note that you also need node in your $PATH.

    Another way that works for me is using the -exec option of go test:

    GOOS=js GOARCH=wasm go test -exec="node $(go env GOROOT)/misc/wasm/wasm_exec"
    

    But it is only useful for giving additional options to node (not possible when using go_js_wasm_exec).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 求数学坐标画圆以及直线的算法
  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决