summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-05-31 06:53:40 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-06-01 10:36:03 +0900
commit835d1f38e7f164393494191a5a58b29c8c9a88ac (patch)
tree25194877be0cfbe1098cb38cab82817adbe3bbb8 /test
parented23fbe22bde2c554b17355ae36df3cedc9cdfe2 (diff)
test: test go example embeded in document
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'test')
-rw-r--r--test/scenario_test/ci-scripts/build_embeded_go.py26
-rw-r--r--test/scenario_test/ci-scripts/travis-build-script.sh5
2 files changed, 30 insertions, 1 deletions
diff --git a/test/scenario_test/ci-scripts/build_embeded_go.py b/test/scenario_test/ci-scripts/build_embeded_go.py
new file mode 100644
index 00000000..1fc70bca
--- /dev/null
+++ b/test/scenario_test/ci-scripts/build_embeded_go.py
@@ -0,0 +1,26 @@
+import sys
+import os
+from subprocess import call
+
+def cut(filename, out):
+ with open(filename, 'r') as f:
+ flag = False
+ codes = []
+ for line in f.readlines():
+ if line.strip() == '```go':
+ flag = True
+ elif line.strip() == '```':
+ with open(out, 'w') as g:
+ g.write("".join(codes))
+ return
+ elif flag:
+ codes.append(line)
+
+if __name__ == '__main__':
+ filename = sys.argv[1]
+ out = '/tmp/test.go'
+ cut(filename, out)
+ ret = call(['go', 'build', '-o', '/tmp/test', out])
+ os.remove(out)
+ os.remove('/tmp/test')
+ sys.exit(ret)
diff --git a/test/scenario_test/ci-scripts/travis-build-script.sh b/test/scenario_test/ci-scripts/travis-build-script.sh
index ef436303..9a7a416d 100644
--- a/test/scenario_test/ci-scripts/travis-build-script.sh
+++ b/test/scenario_test/ci-scripts/travis-build-script.sh
@@ -2,10 +2,14 @@
SCENARIO=$1
echo "travis-build-script.sh"
+export GOBGP=`pwd`
+
if [ "$SCENARIO" != "true" ]; then
echo "execute unit test."
go version
go test -v ./...
+ [ "$?" != 0 ] && exit "$?"
+ python $GOBGP/test/scenario_test/ci-scripts/build_embeded_go.py $GOBGP/docs/sources/lib.md
exit $?
fi
@@ -14,7 +18,6 @@ docker version
echo ""
export GOBGP_IMAGE=gobgp
-export GOBGP=`pwd`
sudo apt-get -q update
sudo apt-get -q -y install iputils-arping bridge-utils lv