From cdce2bab5a7b5c6901c288dd866c11bd95eb5598 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Sun, 10 Mar 2019 23:26:58 -0600 Subject: [PATCH 1/2] Add bin testing requirements --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 839fd80a32..791fb0645d 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,8 @@ import subprocess, os, tempfile test_deps = [ - 'pytest>=3.6', + 'pytest>=3.9', + 'pytest-console-scripts==0.1.9', 'pytest-cov==2.4.0', 'coveralls[yaml]==1.6.0', 'pytest-xdist==1.18.1', From 115f24ea3495609c4aa3fd4a26ce60f9c36c39f5 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Sun, 10 Mar 2019 23:37:03 -0600 Subject: [PATCH 2/2] Add some basic tests --- tests/bin/test_vyper.py | 61 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 tests/bin/test_vyper.py diff --git a/tests/bin/test_vyper.py b/tests/bin/test_vyper.py new file mode 100644 index 0000000000..337f74604b --- /dev/null +++ b/tests/bin/test_vyper.py @@ -0,0 +1,61 @@ +import itertools + +import pytest + +from vyper import ( + __version__, +) + + +@pytest.fixture +def make_tmp_vy_file(tmp_path): + name_count = itertools.count() + + def _make(src): + name = f'tmp{next(name_count)}.vy' + + src_path = tmp_path / name + src_path.write_text(src) + + return src_path + + return _make + + +@pytest.fixture +def tmp_vy_file_1(make_tmp_vy_file): + return make_tmp_vy_file(""" +@public +def a() -> bool: + return True + """) + + +@pytest.fixture +def tmp_vy_file_2(make_tmp_vy_file): + return make_tmp_vy_file(""" +@public +def meaning_of_life() -> uint256: + return 42 + """) + + +@pytest.mark.script_launch_mode('subprocess') +def test_version(script_runner): + ret = script_runner.run('vyper', '--version') + + assert ret.stdout == __version__ + '\n' + + +@pytest.mark.script_launch_mode('subprocess') +def test_compile_one_file(script_runner, tmp_vy_file_1): + ret = script_runner.run('vyper', '-f', 'bytecode', tmp_vy_file_1) + + assert ret.stdout == '0x6100c256600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052630dbe671f60005114156100b85734156100ac57600080fd5b600160005260206000f3005b60006000fd5b6100046100c2036100046000396100046100c2036000f3\n' # noqa: E501 + + +@pytest.mark.script_launch_mode('subprocess') +def test_compile_two_files(script_runner, tmp_vy_file_1, tmp_vy_file_2): + ret = script_runner.run('vyper', '-f', 'bytecode', tmp_vy_file_1, tmp_vy_file_2) + + assert ret.stdout == '0x6100c256600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052630dbe671f60005114156100b85734156100ac57600080fd5b600160005260206000f3005b60006000fd5b6100046100c2036100046000396100046100c2036000f3\n0x6100c256600035601c52740100000000000000000000000000000000000000006020526f7fffffffffffffffffffffffffffffff6040527fffffffffffffffffffffffffffffffff8000000000000000000000000000000060605274012a05f1fffffffffffffffffffffffffdabf41c006080527ffffffffffffffffffffffffed5fa0e000000000000000000000000000000000060a052634f452d6060005114156100b85734156100ac57600080fd5b602a60005260206000f3005b60006000fd5b6100046100c2036100046000396100046100c2036000f3\n' # noqa: E501