Skip to content

Commit

Permalink
Fix tox and windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed May 23, 2020
1 parent 1008009 commit 41dd53c
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 15 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ clean:
rm -rf build/
rm -rf dist/
rm -rf *.egg-info
rm -rf .tox/
find . -name __pycache__ -exec rm -rf {} \;
find . -name .mypy_cache -exec rm -rf {} \;
find . -name .pytest_cache -exec rm -rf {} \;
Expand Down
11 changes: 6 additions & 5 deletions deposit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@

if [[ "$OSTYPE" == "linux-gnu"* ]] || [[ "$OSTYPE" == "darwin"* ]]; then
echo $OSTYPE

if [[ $1 == install ]]; then
if [[ $1 == "install" ]]; then
echo "Installing dependencies..."
python3 -m pip3 install -r requirements.txt
python3 setup.py install
exit 1
fi

echo "Running deposit-cli..."
python3 ./eth2deposit/deposit.py "$@"

elif [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "cygwin" ]]; then
echo $OSTYPE
if [[ $1 == install ]]; then
if [[ $1 == "install" ]]; then
echo "Installing dependencies..."
python -m pip install -r requirements.txt
python setup.py install
exit 1
fi

echo "Running deposit-cli..."
python ./eth2deposit/deposit.py "$@"

else
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@

setup(
name="eth2deposit",
version='0.0.0',
py_modules=["eth2deposit"],
packages=find_packages(exclude=('tests', 'docs')),
python_requires=">=3.7,<4",
)
16 changes: 12 additions & 4 deletions test_deposit_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,26 @@ async def main():
os.mkdir(my_folder_path)

if os.name == 'nt': # Windows
script = 'sh deposit.sh'
run_script_cmd = 'sh deposit.sh'
else: # Mac or Linux
script = './deposit.sh'
run_script_cmd = './deposit.sh'

install_cmd = run_script_cmd + ' install'
print('[INFO] Creating subprocess 1: installation:' , install_cmd)
proc = await asyncio.create_subprocess_shell(
install_cmd,
)
await proc.wait()
print('[INFO] Installed')

cmd_args = [
script,
run_script_cmd,
'--num_validators', '1',
'--mnemonic_language', 'english',
'--password', 'MyPassword',
'--folder', my_folder_path,
]
print('[INFO] Creating subprocess')
print('[INFO] Creating subprocess 2: deposit-cli')
proc = await asyncio.create_subprocess_shell(
' '.join(cmd_args),
stdin=asyncio.subprocess.PIPE,
Expand Down
13 changes: 9 additions & 4 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,19 @@ async def test_script():
if not os.path.exists(my_folder_path):
os.mkdir(my_folder_path)

if os.name == 'nt': # Windows
run_script_cmd = 'sh deposit.sh'
else: # Mac or Linux
run_script_cmd = './deposit.sh'

install_cmd = run_script_cmd + ' install'
proc = await asyncio.create_subprocess_shell(
'./deposit.sh install',
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
install_cmd,
)
await proc.wait()

cmd_args = [
'./deposit.sh',
run_script_cmd,
'--num_validators', '1',
'--mnemonic_language', 'english',
'--password', 'MyPassword',
Expand Down
10 changes: 8 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ envlist=
py{37,38}-script

[testenv]
usedevelop=True
passenv=
PYTEST_ADDOPTS
extras = test
basepython=
py37: python3.7
py38: python3.8

[common-install]
deps=
-r{toxinidir}/requirements.txt
-r{toxinidir}/requirements_test.txt

[common-core]
deps={[common-install]deps}
commands=
pytest {posargs:tests}

[common-lint]
deps={[common-install]deps}
commands=
flake8 --config={toxinidir}/flake8.ini {toxinidir}/cli {toxinidir}/tests
mypy --config-file {toxinidir}/mypy.ini -p eth2deposit
Expand All @@ -32,15 +34,19 @@ commands=
python {toxinidir}/test_deposit_script.py

[testenv:py37-core]
deps={[common-core]deps}
commands={[common-core]commands}

[testenv:py38-core]
deps={[common-core]deps}
commands={[common-core]commands}

[testenv:py37-lint]
deps={[common-lint]deps}
commands={[common-lint]commands}

[testenv:py38-lint]
deps={[common-lint]deps}
commands={[common-lint]commands}

[testenv:py37-script]
Expand Down

0 comments on commit 41dd53c

Please sign in to comment.