Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
Fix default value of compiler attribute to par_binary() (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
Douglas Greiman committed Jan 29, 2018
1 parent 1f6a460 commit 741dbb0
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
4 changes: 2 additions & 2 deletions subpar.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down
9 changes: 9 additions & 0 deletions tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
8 changes: 8 additions & 0 deletions tests/test_compiler_label_wrapper.sh
Original file line number Diff line number Diff line change
@@ -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"
11 changes: 11 additions & 0 deletions tests/test_workspace/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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",
)
26 changes: 26 additions & 0 deletions tests/test_workspace/test_compiler_label.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 741dbb0

Please sign in to comment.