From 835d1f38e7f164393494191a5a58b29c8c9a88ac Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Tue, 31 May 2016 06:53:40 +0000 Subject: test: test go example embeded in document Signed-off-by: ISHIDA Wataru --- test/scenario_test/ci-scripts/build_embeded_go.py | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test/scenario_test/ci-scripts/build_embeded_go.py (limited to 'test/scenario_test/ci-scripts/build_embeded_go.py') 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) -- cgit v1.2.3