-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use pytest for brownie integration test in CI
- Loading branch information
1 parent
6c92aae
commit 61aa127
Showing
4 changed files
with
50 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,19 @@ | ||
import os | ||
import shutil | ||
import tempfile | ||
import subprocess | ||
import pytest | ||
from typing import List | ||
|
||
# cmd = [sys.executable, "-m", "pip", "install", "eth-brownie"] | ||
|
||
import logging | ||
LOGGER = logging.getLogger(__name__) | ||
|
||
def run(command: List[str], cwd: str) -> int: | ||
process = subprocess.run( | ||
command, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
executable=shutil.which(command[0]), | ||
cwd=cwd, | ||
check=True | ||
) | ||
LOGGER.info(process.stdout.decode("utf-8")) | ||
LOGGER.error(process.stderr.decode("utf-8")) | ||
return process.returncode | ||
|
||
brownie_available = shutil.which("brownie") is not None | ||
@pytest.mark.skip_if(not brownie_available) | ||
def test_brownie(): | ||
def test_brownie(make_tmpdir, run_command): | ||
tmpdirname = make_tmpdir | ||
|
||
initialize = ["brownie", "bake", "token"] | ||
test = ["crytic-compile", ".", "--compile-force-framework", "brownie"] | ||
|
||
with tempfile.TemporaryDirectory() as tmpdirname: | ||
|
||
run(initialize, tmpdirname) | ||
run_command(initialize, tmpdirname) | ||
project_dir = os.path.join(tmpdirname,"token") | ||
assert os.path.isdir(project_dir) | ||
assert run_command(test, project_dir) == 0 | ||
|
||
run(test,os.path.join(tmpdirname,"token")) == 0 | ||
|
||
|