Skip to content

Commit 00b9b13

Browse files
committed
Move test/dev requirements into standardized format across boto projects
1 parent 226f4a9 commit 00b9b13

File tree

7 files changed

+109
-26
lines changed

7 files changed

+109
-26
lines changed

requirements-dev.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
nose==1.3.7
2+
wheel==0.37.0
3+
behave==1.2.5
4+
jsonschema==2.5.1
5+
coverage==5.5
6+
7+
# Pytest specific deps
8+
pytest==6.2.5
9+
pytest-cov==2.12.1
10+
atomicwrites>=1.0 # Windows requirement
11+
colorama>0.3.0 # Windows requirement

requirements.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
tox>=2.5.0,<3.0.0
2-
nose==1.3.7
3-
mock==1.3.0
4-
wheel==0.36.2
5-
behave==1.2.5
6-
jsonschema==2.5.1
1+
-r requirements-dev.txt

scripts/ci/install

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,44 @@
11
#!/usr/bin/env python
22
import argparse
33
import os
4-
import sys
5-
from subprocess import check_call
64
import shutil
5+
from contextlib import contextmanager
6+
from subprocess import check_call
77

88
_dname = os.path.dirname
99

1010
REPO_ROOT = _dname(_dname(_dname(os.path.abspath(__file__))))
11-
os.chdir(REPO_ROOT)
11+
12+
13+
@contextmanager
14+
def cd(path):
15+
"""Change directory while inside context manager."""
16+
cwd = os.getcwd()
17+
try:
18+
os.chdir(path)
19+
yield
20+
finally:
21+
os.chdir(cwd)
1222

1323

1424
def run(command):
1525
return check_call(command, shell=True)
1626

27+
1728
if __name__ == "__main__":
1829
parser = argparse.ArgumentParser()
1930
group = parser.add_mutually_exclusive_group()
2031
group.add_argument(
2132
'-e', '--extras', help='Install extras_require along with normal install'
2233
)
2334
args = parser.parse_args()
24-
run('pip install -r requirements.txt')
25-
run('pip install coverage')
26-
if os.path.isdir('dist') and os.listdir('dist'):
27-
shutil.rmtree('dist')
28-
run('python setup.py bdist_wheel')
29-
wheel_dist = os.listdir('dist')[0]
30-
package = os.path.join('dist', wheel_dist)
31-
if args.extras:
32-
package = "'%s[%s]'" % (package, args.extras)
33-
run('pip install %s' % package)
35+
with cd(REPO_ROOT):
36+
run("python scripts/ci/install-dev-deps")
37+
if os.path.isdir("dist") and os.listdir("dist"):
38+
shutil.rmtree("dist")
39+
run("python setup.py bdist_wheel")
40+
wheel_dist = os.listdir("dist")[0]
41+
package = os.path.join('dist', wheel_dist)
42+
if args.extras:
43+
package = "'%s[%s]'" % (package, args.extras)
44+
run('pip install %s' % package)

scripts/ci/install-dev-deps

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
import os
3+
from contextlib import contextmanager
4+
from subprocess import check_call
5+
6+
_dname = os.path.dirname
7+
8+
REPO_ROOT = _dname(_dname(_dname(os.path.abspath(__file__))))
9+
10+
11+
@contextmanager
12+
def cd(path):
13+
"""Change directory while inside context manager."""
14+
cwd = os.getcwd()
15+
try:
16+
os.chdir(path)
17+
yield
18+
finally:
19+
os.chdir(cwd)
20+
21+
22+
def run(command):
23+
return check_call(command, shell=True)
24+
25+
26+
if __name__ == "__main__":
27+
with cd(REPO_ROOT):
28+
run("pip install -r requirements-dev-lock.txt")

scripts/ci/run-crt-tests

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,23 @@
55

66
import os
77
import sys
8+
from contextlib import contextmanager
89
from subprocess import check_call
910

1011
_dname = os.path.dirname
1112

1213
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)
1425

1526

1627
def run(command):
@@ -23,4 +34,6 @@ except ImportError:
2334
print("MISSING DEPENDENCY: awscrt must be installed to run the crt tests.")
2435
sys.exit(1)
2536

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/")

scripts/ci/run-integ-tests

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,29 @@
44
# binary package not from the CWD.
55

66
import os
7+
from contextlib import contextmanager
78
from subprocess import check_call
89

910
_dname = os.path.dirname
1011

1112
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)
1324

1425

1526
def run(command):
1627
return check_call(command, shell=True)
1728

1829

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")

scripts/ci/run-tests

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,24 @@
55

66
import argparse
77
import os
8+
from contextlib import contextmanager
89
from subprocess import check_call
910

1011
_dname = os.path.dirname
1112

1213
REPO_ROOT = _dname(_dname(_dname(os.path.abspath(__file__))))
1314
PACKAGE = "botocore"
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)
1526

1627

1728
def run(command):
@@ -20,7 +31,7 @@ def run(command):
2031

2132
def process_args(args):
2233
runner = args.test_runner
23-
test_args = ''
34+
test_args = ""
2435
if args.with_cov:
2536
test_args += (
2637
f"--with-xunit --cover-erase --with-coverage "
@@ -57,4 +68,5 @@ if __name__ == "__main__":
5768

5869
cmd = f"{test_runner} {test_args}{test_dirs}"
5970
print(f"Running {cmd}...")
60-
run(cmd)
71+
with cd(os.path.join(REPO_ROOT, "tests")):
72+
run(cmd)

0 commit comments

Comments
 (0)