1#!/bin/bash
2set -euox pipefail
3IFS=$'\n\t'
4
5# This script creates a fake GOPATH, symlinks in the current
6# directory as uber-go/atomic and verifies that tests still pass.
7
8WORK_DIR=`mktemp -d`
9function cleanup {
10	rm -rf "$WORK_DIR"
11}
12trap cleanup EXIT
13
14
15export GOPATH="$WORK_DIR"
16PKG_PARENT="$WORK_DIR/src/github.com/uber-go"
17PKG_DIR="$PKG_PARENT/atomic"
18
19mkdir -p "$PKG_PARENT"
20cp -R `pwd` "$PKG_DIR"
21cd "$PKG_DIR"
22
23# The example imports go.uber.org, fix the import.
24sed -e 's/go.uber.org\/atomic/github.com\/uber-go\/atomic/' -i="" example_test.go
25
26make test
27