aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Yun Peng <pcloudy@google.com>2016-08-09 17:54:11 +0000
committerGravatar Yue Gan <yueg@google.com>2016-08-10 08:37:43 +0000
commit679e911e948e6965afe1c23bb20ac4efdd65bac4 (patch)
tree9b743c7cecbe501d279e5172b5fb24e7850fc056 /src/test
parent3f814d72af4c86edfe997a5bb2217e6f753f16b1 (diff)
Using stub_template.txt as __main__.py and zip header in python executable zip
In stub_template.txt, we now unzip the python zip file to a temp directory if needed. This will get rid of bash in python executable file completely. Users can run the binary directly or using python <zip>, like: ./bazel-bin/examples/py_native/bin or python ./bazel-bin/examples/py_native/bin On Windows, we can use the second way to run python binary from native Windows command line (cmd.exe). -- Change-Id: I73fdd88f05f8f343dd19b2f3686ae031dfb476ba Reviewed-on: https://bazel-review.googlesource.com/#/c/5310 MOS_MIGRATED_REVID=129767890
Diffstat (limited to 'src/test')
-rwxr-xr-xsrc/test/shell/bazel/bazel_example_test.sh14
-rwxr-xr-xsrc/test/shell/bazel/bazel_windows_example_test.sh20
2 files changed, 34 insertions, 0 deletions
diff --git a/src/test/shell/bazel/bazel_example_test.sh b/src/test/shell/bazel/bazel_example_test.sh
index 93075fddb6..c440a6eeae 100755
--- a/src/test/shell/bazel/bazel_example_test.sh
+++ b/src/test/shell/bazel/bazel_example_test.sh
@@ -113,6 +113,20 @@ function test_native_python() {
assert_test_fails //examples/py_native:fail --python2_path=python
}
+function test_native_python_with_zip() {
+ assert_build //examples/py_native:bin --python2_path=python --build_python_zip
+ # run the python package directly
+ ./bazel-bin/examples/py_native/bin >& $TEST_log \
+ || fail "//examples/py_native:bin execution failed"
+ expect_log "Fib(5) == 8"
+ # Using python <zipfile> to run the python package
+ python ./bazel-bin/examples/py_native/bin >& $TEST_log \
+ || fail "//examples/py_native:bin execution failed"
+ expect_log "Fib(5) == 8"
+ assert_test_ok //examples/py_native:test --python2_path=python --build_python_zip
+ assert_test_fails //examples/py_native:fail --python2_path=python --build_python_zip
+}
+
function test_shell() {
assert_build "//examples/shell:bin"
assert_bazel_run "//examples/shell:bin" "Hello Bazel!"
diff --git a/src/test/shell/bazel/bazel_windows_example_test.sh b/src/test/shell/bazel/bazel_windows_example_test.sh
index c0bd25b54e..ab31786199 100755
--- a/src/test/shell/bazel/bazel_windows_example_test.sh
+++ b/src/test/shell/bazel/bazel_windows_example_test.sh
@@ -84,5 +84,25 @@ function test_java_test() {
assert_test_fails "${java_native_tests}:resource-fail"
}
+function test_native_python() {
+ assert_build //examples/py_native:bin --python2_path=python
+ assert_test_ok //examples/py_native:test --python2_path=python
+ assert_test_fails //examples/py_native:fail --python2_path=python
+}
+
+function test_native_python_with_zip() {
+ assert_build //examples/py_native:bin --python2_path=python --build_python_zip
+ # run the python package directly
+ ./bazel-bin/examples/py_native/bin >& $TEST_log \
+ || fail "//examples/py_native:bin execution failed"
+ expect_log "Fib(5) == 8"
+ # Using python <zipfile> to run the python package
+ python ./bazel-bin/examples/py_native/bin >& $TEST_log \
+ || fail "//examples/py_native:bin execution failed"
+ expect_log "Fib(5) == 8"
+ assert_test_ok //examples/py_native:test --python2_path=python --build_python_zip
+ assert_test_fails //examples/py_native:fail --python2_path=python --build_python_zip
+}
+
run_suite "examples on Windows"