Skip to content

Commit

Permalink
python3: make path to unit test absolute
Browse files Browse the repository at this point in the history
When Tarantool unit tests runs using test-run error with output like below
may happen:

[027] small/small_class.test
[027] Test.run() received the following error:
[027] Traceback (most recent call last):
[027]   File "/__w/tarantool/tarantool/test-run/lib/test.py", line 192, in run
[027]     self.execute(server)
[027]   File "/__w/tarantool/tarantool/test-run/lib/unittest_server.py", line 20, in execute
[027]     proc = Popen(execs, cwd=server.vardir, stdout=PIPE, stderr=STDOUT)
[027]   File "/usr/lib/python3.5/subprocess.py", line 676, in __init__
[027]     restore_signals, start_new_session)
[027]   File "/usr/lib/python3.5/subprocess.py", line 1282, in _execute_child
[027]     raise child_exception_type(errno_num, err_msg)
[027] FileNotFoundError: [Errno 2] No such file or directory: '../test/small/small_class.test'
[027] [ fail ]

The root cause of error is changed behaviour of Popen in Python 3 in comparison
to Python 2. One should explicitly set path to a current work dir:

Python 2 [1]: "If cwd is not None, the child’s current directory will be
changed to cwd before it is executed. Note that this directory is not
considered when searching the executable, so you can’t specify the
program’s path relative to cwd."

Python 3 [2]: "If cwd is not None, the function changes the working
directory to cwd before executing the child. <...> In particular, the
function looks for executable (or for the first item in args) relative
to cwd if the executable path is a relative path."

1. https://docs.python.org/2/library/subprocess.html#subprocess.Popen
2. https://docs.python.org/3/library/subprocess.html#subprocess.Popen

Part of #20
  • Loading branch information
ligurio authored and Totktonada committed Mar 13, 2021
1 parent 1b8de04 commit 898a399
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/unittest_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def binary(self):
def prepare_args(self, args=[]):
executable_path = os.path.join(self.builddir, "test",
self.current_test.name)
return [executable_path] + args
return [os.path.abspath(executable_path)] + args

def deploy(self, vardir=None, silent=True, wait=True):
self.vardir = vardir
Expand Down

0 comments on commit 898a399

Please sign in to comment.