Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to pytest #361

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-2022"]
type: ["brownie", "buidler", "dapp", "embark", "etherlime", "hardhat", "solc", "truffle", "waffle", "foundry", "standard"]
type: ["brownie"]
# "buidler", "dapp", "embark", "etherlime", "hardhat", "solc", "truffle", "waffle", "foundry", "standard"]
exclude:
# Currently broken, tries to pull git:// which is blocked by GH
- type: embark
Expand Down Expand Up @@ -73,3 +74,4 @@ jobs:
shell: bash
run: |
bash "scripts/ci_test_${TEST_TYPE}.sh"
pytest -k $TEST_TYPE
16 changes: 8 additions & 8 deletions scripts/ci_test_brownie.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env bash

pip install eth-brownie
brownie bake token
cd token || exit 255
# brownie bake token
# cd token || exit 255

crytic-compile . --compile-force-framework Brownie
# crytic-compile . --compile-force-framework Brownie

if [ $? -ne 0 ]
then
echo "Brownie test failed"
exit 255
fi
# if [ $? -ne 0 ]
# then
# echo "Brownie test failed"
# exit 255
# fi
32 changes: 32 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import shutil
import tempfile
import subprocess
import pytest
from typing import List

@pytest.fixture
def make_tmpdir():
with tempfile.TemporaryDirectory() as tmpdirname:
yield tmpdirname


import logging
LOGGER = logging.getLogger(__name__)

@pytest.fixture
def run_command():
def _run(command: List[str], cwd: str) -> int:
executable = shutil.which(command[0])
assert executable
process = subprocess.run(
command,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
executable=executable,
cwd=cwd,
check=True
)
LOGGER.info(process.stdout.decode("utf-8"))
LOGGER.error(process.stderr.decode("utf-8"))
return process.returncode
return _run
19 changes: 19 additions & 0 deletions tests/test_brownie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import shutil
import pytest

brownie_available = shutil.which("brownie") is not None
@pytest.mark.skip_if(not brownie_available)
def test_brownie(make_tmpdir, run_command):
tmpdirname = make_tmpdir

initialize = ["brownie", "bake", "token"]
test = ["crytic-compile", ".", "--compile-force-framework", "brownie"]

run_command(initialize, tmpdirname)
project_dir = os.path.join(tmpdirname,"token")
assert os.path.isdir(project_dir)
assert run_command(test, project_dir) == 0