-
-
Notifications
You must be signed in to change notification settings - Fork 663
Closed as not planned
Closed as not planned
Copy link
Description
🐞 bug report
Affected Rule
pyt_test
Is this a regression?
No
Description
py_test gives err if the value of the name arg is not the same as the test python script name. eg:
py_test(
name = "test_script",
srcs = ["test_module1/test_script1.py"],
deps = [
"//src:module1",
],
# main = "test_module1/test_script1.py",
)
py_test(
name = "test_script2",
srcs = ["test_module2/test_script2.py"],
deps = [
"//src:module2",
],
# main = "test_module2/test_script2.py",
)
If I change the value of the name args something different from test_Script1.py or test_Script2.py, I got this err:
bazel test //tests:all
WARNING: Build option --python_path has changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
ERROR: C:/users/chaha/git/python/pytest/tests/BUILD:1:8: in py_test rule //tests:test_script_xxx:
Traceback (most recent call last):
File "/virtual_builtins_bzl/common/python/py_test_bazel.bzl", line 43, column 41, in _py_test_impl
File "/virtual_builtins_bzl/common/python/py_executable_bazel.bzl", line 97, column 37, in py_executable_bazel_impl
File "/virtual_builtins_bzl/common/python/py_executable.bzl", line 110, column 29, in py_executable_base_impl
File "/virtual_builtins_bzl/common/python/py_executable.bzl", line 638, column 17, in determine_main
Error in fail: corresponding default 'test_script_xxx.py' does not appear in srcs. Add it or override default file name with a 'main' attribute
ERROR: C:/users/chaha/git/python/pytest/tests/BUILD:1:8: Analysis of target '//tests:test_script_xxx' failed
ERROR: Analysis of target '//tests:test_script_xxx' failed; build aborted
INFO: Elapsed time: 0.805s, Critical Path: 0.02s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: No test targets were found, yet testing was requested
~~~
However, if I give the main attribute with test script path then it works perfectly:
main = "test_module1/test_script1.py",
## 🌍 Your Environment
issue coming on both windows and mac with latest bazel version
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels