|
0 |
from __future__ import absolute_import, division, print_function
|
|
1 |
|
|
2 |
import os
|
|
3 |
import sys
|
|
4 |
|
|
5 |
import procrunner
|
|
6 |
import pytest
|
|
7 |
|
|
8 |
@pytest.mark.skipif(sys.platform != 'win32', reason="windows specific test only")
|
|
9 |
def test_name_resolution_for_simple_exe():
|
|
10 |
command = ['cmd.exe', '/c', 'echo', 'hello']
|
|
11 |
|
|
12 |
resolved = procrunner._windows_resolve(command)
|
|
13 |
|
|
14 |
# command should be replaced with full path to cmd.exe
|
|
15 |
assert resolved[0].lower().endswith('\\cmd.exe')
|
|
16 |
assert os.path.exists(resolved[0])
|
|
17 |
|
|
18 |
# parameters are unchanged
|
|
19 |
assert resolved[1:] == command[1:]
|
|
20 |
|
|
21 |
@pytest.mark.skipif(sys.platform != 'win32', reason="windows specific test only")
|
|
22 |
def test_name_resolution_for_complex_cases(tmpdir):
|
|
23 |
tmpdir.chdir()
|
|
24 |
|
|
25 |
bat = 'simple_bat_extension'
|
|
26 |
cmd = 'simple_cmd_extension'
|
|
27 |
exe = 'simple_exe_extension'
|
|
28 |
dotshort = 'more_complex_filename_with_a.dot'
|
|
29 |
dotlong = 'more_complex_filename.withadot'
|
|
30 |
|
|
31 |
(tmpdir / bat + '.bat').ensure()
|
|
32 |
(tmpdir / cmd + '.cmd').ensure()
|
|
33 |
(tmpdir / exe + '.exe').ensure()
|
|
34 |
(tmpdir / dotshort + '.bat').ensure()
|
|
35 |
(tmpdir / dotlong + '.cmd').ensure()
|
|
36 |
|
|
37 |
def is_valid(command):
|
|
38 |
assert len(command) == 1
|
|
39 |
assert os.path.exists(command[0])
|
|
40 |
|
|
41 |
is_valid(procrunner._windows_resolve([bat]))
|
|
42 |
is_valid(procrunner._windows_resolve([cmd]))
|
|
43 |
is_valid(procrunner._windows_resolve([exe]))
|
|
44 |
is_valid(procrunner._windows_resolve([dotshort]))
|
|
45 |
is_valid(procrunner._windows_resolve([dotlong]))
|