diff --git a/subpar.bzl b/subpar.bzl index 9134b84..f12230d 100644 --- a/subpar.bzl +++ b/subpar.bzl @@ -189,7 +189,7 @@ def par_binary(name, **kwargs): See [py_binary](http://www.bazel.io/docs/be/python.html#py_binary) for arguments and usage. """ - compiler = kwargs.pop('compiler', DEFAULT_COMPILER) + compiler = kwargs.pop('compiler', None) zip_safe = kwargs.pop('zip_safe', True) native.py_binary(name=name, **kwargs) @@ -216,7 +216,7 @@ def par_test(name, **kwargs): Just like par_binary, but for py_test instead of py_binary. Useful if you specifically need to test a module's behaviour when used in a .par binary. """ - compiler = kwargs.pop('compiler', DEFAULT_COMPILER) + compiler = kwargs.pop('compiler', None) zip_safe = kwargs.pop('zip_safe', True) native.py_test(name=name, **kwargs) diff --git a/tests/BUILD b/tests/BUILD index 43a602c..a87f306 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -184,3 +184,12 @@ par_binary( ("shadow", "//tests:package_shadow/main", "tests/package_shadow/main"), ("version", "//tests:package_f/f", "tests/package_f/f"), ]] + +# Test target in external workspace +sh_test( + name = "test_compiler_label_wrapper", + srcs = ["test_compiler_label_wrapper.sh"], + data = [ + "@test_workspace//:test_compiler_label.par", + ], +) diff --git a/tests/test_compiler_label_wrapper.sh b/tests/test_compiler_label_wrapper.sh new file mode 100755 index 0000000..5376d53 --- /dev/null +++ b/tests/test_compiler_label_wrapper.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -eu + +# Did the par file compile and run? +../test_workspace/test_compiler_label.par || exit 1 + +echo "Pass" diff --git a/tests/test_workspace/BUILD b/tests/test_workspace/BUILD index 23250f7..aec5242 100644 --- a/tests/test_workspace/BUILD +++ b/tests/test_workspace/BUILD @@ -14,8 +14,11 @@ package(default_visibility = ["//visibility:public"]) +load("@subpar//:subpar.bzl", "par_binary") + exports_files(["data_file.txt"]) +# Part of the tests:external_workspace test py_library( name = "package_external_lib/external_lib", srcs = [ @@ -24,3 +27,11 @@ py_library( ], srcs_version = "PY2AND3", ) + +# Test that we can actually compile a par_binary outside the subpar workspace. +par_binary( + name = "test_compiler_label", + srcs = ["test_compiler_label.py"], + main = "test_compiler_label.py", + srcs_version = "PY2AND3", +) diff --git a/tests/test_workspace/test_compiler_label.py b/tests/test_workspace/test_compiler_label.py new file mode 100644 index 0000000..320be4e --- /dev/null +++ b/tests/test_workspace/test_compiler_label.py @@ -0,0 +1,26 @@ +# Copyright 2018 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Integration test program for Subpar. + +Test that the default `compiler` label is correctly resolved. This +test must be done in a workspace other than subpar's workspace. +""" + +def main(): + print('In test_compiler_label.py main()') + + +if __name__ == '__main__': + main()