1#!/usr/bin/env sh 2 3# Test script checking that all expected os/arch compile properly. 4# Does not actually test the logic, just the compilation so we make sure we don't break code depending on the lib. 5 6echo2() { 7 echo $@ >&2 8} 9 10trap end 0 11end() { 12 [ "$?" = 0 ] && echo2 "Pass." || (echo2 "Fail."; exit 1) 13} 14 15cross() { 16 os=$1 17 shift 18 echo2 "Build for $os." 19 for arch in $@; do 20 echo2 " - $os/$arch" 21 GOOS=$os GOARCH=$arch go build 22 done 23 echo2 24} 25 26set -e 27 28cross linux amd64 386 arm arm64 ppc64 ppc64le s390x mips mipsle mips64 mips64le 29cross darwin amd64 arm64 30cross freebsd amd64 386 arm arm64 ppc64 31cross netbsd amd64 386 arm arm64 32cross openbsd amd64 386 arm arm64 33cross dragonfly amd64 34cross solaris amd64 35 36# Not expected to work but should still compile. 37cross windows amd64 386 arm 38 39# TODO: Fix compilation error on openbsd/arm. 40# TODO: Merge the solaris PR. 41 42# Some os/arch require a different compiler. Run in docker. 43if ! hash docker; then 44 # If docker is not present, stop here. 45 return 46fi 47 48echo2 "Build for linux." 49echo2 " - linux/riscv" 50docker build -t creack-pty-test -f Dockerfile.riscv . 51 52# Golang dropped support for darwin 32bits since go1.15. Make sure the lib still compile with go1.14 on those archs. 53echo2 "Build for darwin (32bits)." 54echo2 " - darwin/386" 55docker build -t creack-pty-test -f Dockerfile.golang --build-arg=GOVERSION=1.14 --build-arg=GOOS=darwin --build-arg=GOARCH=386 . 56echo2 " - darwin/arm" 57docker build -t creack-pty-test -f Dockerfile.golang --build-arg=GOVERSION=1.14 --build-arg=GOOS=darwin --build-arg=GOARCH=arm . 58 59# Run a single test for an old go version. Would be best with go1.0, but not available on Dockerhub. 60# Using 1.6 as it is the base version for the RISCV compiler. 61# Would also be better to run all the tests, not just one, need to refactor this file to allow for specifc archs per version. 62echo2 "Build for linux - go1.6." 63echo2 " - linux/amd64" 64docker build -t creack-pty-test -f Dockerfile.golang --build-arg=GOVERSION=1.6 --build-arg=GOOS=linux --build-arg=GOARCH=amd64 . 65