/test_darwin_certs.sh Secret
Last active
February 12, 2017 15:44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -ex | |
( | |
test -d test-darwin-certs || mkdir test-darwin-certs | |
cd test-darwin-certs | |
test -d go || curl -s -L https://storage.googleapis.com/golang/go1.8rc3.darwin-amd64.tar.gz | tar xzv | |
export GOROOT_BOOTSTRAP="$(pwd)/go" | |
export GOROOT="$(pwd)/gosrc" | |
export PATH="$GOROOT/bin:$PATH" | |
if test -d gosrc | |
then | |
cd gosrc | |
git pull | |
else | |
git clone --depth 1 -b darwin_certs https://github.com/mastercactapus/go gosrc | |
cd gosrc | |
fi | |
cd src | |
./make.bash | |
cd ../.. | |
cat >test.go <<EOF | |
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
) | |
const URL = "https://elementary.io/" | |
func main() { | |
fmt.Println("GET", URL) | |
_, err := http.Get(URL) | |
if err != nil { | |
log.Fatal(err) | |
} | |
} | |
EOF | |
_CN=0 | |
_NN=0 | |
_CF=0 | |
_NF=0 | |
export CGO_ENABLED=1 | |
echo "Testing CGO_ENABLED=1 -- Go 1.8 (with fix)" | |
go run test.go && echo "PASS (yay!)" && _CF=1 || echo "FAIL (fix didn't work')" | |
export CGO_ENABLED=0 | |
echo "Testing CGO_ENABLED=0 -- Go 1.8 (with fix)" | |
go run test.go && echo "PASS (yay!)" && _NF=1 || echo "FAIL (fix didn't work')" | |
export GOROOT="$GOROOT_BOOTSTRAP" | |
export PATH="$GOROOT/bin:$PATH" | |
export CGO_ENABLED=1 | |
echo "Testing CGO_ENABLED=1 -- Go 1.8" | |
go run test.go && echo "PASS (should have failed)" && _CN=1 || echo "FAIL (this is expected)" | |
export CGO_ENABLED=0 | |
echo "Testing CGO_ENABLED=0 -- Go 1.8" | |
go run test.go && echo "PASS (should have failed)" && _NN=1 || echo "FAIL (this is expected)" | |
set +x | |
echo | |
echo "The important part:" | |
echo | |
echo "************" | |
echo "CGO 1.8: $_CN" | |
echo "NOCGO 1.8: $_NN" | |
echo "CGO fix: $_CF" | |
echo "NOCGO fix: $_NF" | |
echo "************" | |
echo | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment