File tree 3 files changed +45
-7
lines changed
3 files changed +45
-7
lines changed Original file line number Diff line number Diff line change 5
5
6
6
import os
7
7
import sys
8
+ from contextlib import contextmanager
8
9
from subprocess import check_call
9
10
10
11
_dname = os .path .dirname
11
12
12
13
REPO_ROOT = _dname (_dname (_dname (os .path .abspath (__file__ ))))
13
- os .chdir (os .path .join (REPO_ROOT , "tests" ))
14
+
15
+
16
+ @contextmanager
17
+ def cd (path ):
18
+ """Change directory while inside context manager."""
19
+ cwd = os .getcwd ()
20
+ try :
21
+ os .chdir (path )
22
+ yield
23
+ finally :
24
+ os .chdir (cwd )
14
25
15
26
16
27
def run (command ):
@@ -23,4 +34,6 @@ except ImportError:
23
34
print ("MISSING DEPENDENCY: awscrt must be installed to run the crt tests." )
24
35
sys .exit (1 )
25
36
26
- run (f'{ REPO_ROOT } /scripts/ci/run-tests unit/ functional/' )
37
+ if __name__ == "__main__" :
38
+ with cd (os .path .join (REPO_ROOT , "tests" )):
39
+ run (f"{ REPO_ROOT } /scripts/ci/run-tests unit/ functional/" )
Original file line number Diff line number Diff line change 4
4
# binary package not from the CWD.
5
5
6
6
import os
7
+ from contextlib import contextmanager
7
8
from subprocess import check_call
8
9
9
10
_dname = os .path .dirname
10
11
11
12
REPO_ROOT = _dname (_dname (_dname (os .path .abspath (__file__ ))))
12
- os .chdir (os .path .join (REPO_ROOT , "tests" ))
13
+
14
+
15
+ @contextmanager
16
+ def cd (path ):
17
+ """Change directory while inside context manager."""
18
+ cwd = os .getcwd ()
19
+ try :
20
+ os .chdir (path )
21
+ yield
22
+ finally :
23
+ os .chdir (cwd )
13
24
14
25
15
26
def run (command ):
16
27
return check_call (command , shell = True )
17
28
18
29
19
- run (f"{ REPO_ROOT } /scripts/ci/run-tests --with-cov integration" )
30
+ if __name__ == "__main__" :
31
+ with cd (os .path .join (REPO_ROOT , "tests" )):
32
+ run (f"{ REPO_ROOT } /scripts/ci/run-tests --with-cov integration" )
Original file line number Diff line number Diff line change 5
5
6
6
import argparse
7
7
import os
8
+ from contextlib import contextmanager
8
9
from subprocess import check_call
9
10
10
11
_dname = os .path .dirname
11
12
12
13
REPO_ROOT = _dname (_dname (_dname (os .path .abspath (__file__ ))))
13
14
PACKAGE = "boto3"
14
- os .chdir (os .path .join (REPO_ROOT , "tests" ))
15
+
16
+
17
+ @contextmanager
18
+ def cd (path ):
19
+ """Change directory while inside context manager."""
20
+ cwd = os .getcwd ()
21
+ try :
22
+ os .chdir (path )
23
+ yield
24
+ finally :
25
+ os .chdir (cwd )
15
26
16
27
17
28
def run (command ):
@@ -20,7 +31,7 @@ def run(command):
20
31
21
32
def process_args (args ):
22
33
runner = args .test_runner
23
- test_args = ''
34
+ test_args = ""
24
35
if args .with_cov :
25
36
test_args += (
26
37
f"--with-xunit --cover-erase --with-coverage "
@@ -57,4 +68,5 @@ if __name__ == "__main__":
57
68
58
69
cmd = f"{ test_runner } { test_args } { test_dirs } "
59
70
print (f"Running { cmd } ..." )
60
- run (cmd )
71
+ with cd (os .path .join (REPO_ROOT , "tests" )):
72
+ run (cmd )
You can’t perform that action at this time.
0 commit comments