Skip to content

Add test runner python module #318

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

Merged
merged 41 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
3b825fd
add test runner module
anvacaru Oct 12, 2021
0c749ed
kiele-coverage script which generates a frontend JSON report from build
gtrepta Oct 14, 2021
b953c94
pyiele/config.py: Put config variable into config class
gtrepta Oct 18, 2021
a8cfa25
kiele: Add coverage command
gtrepta Oct 18, 2021
a7f7977
kiele: Add coverage command
gtrepta Oct 18, 2021
1444d0d
pyiele: compile solidity contract
anvacaru Oct 19, 2021
9a877e8
pyiele/utils.py: add basic assert functionality
anvacaru Oct 19, 2021
76a1310
pyiele: run Solidity tests; compile folders
anvacaru Oct 19, 2021
1484a53
fix typo
anvacaru Oct 19, 2021
4ce998a
pyiele: add blackbox tester
anvacaru Oct 20, 2021
ee441b1
pyiele/transactionGeneration: fix generate_cons_args
anvacaru Oct 20, 2021
f2a2202
add kiele commands
anvacaru Oct 21, 2021
f876181
pyiele: remove time.sleep() usage
anvacaru Oct 21, 2021
9efc1f1
kiele: fix test command
anvacaru Oct 21, 2021
7c773b7
pyiele: run solidity tests
anvacaru Oct 21, 2021
f6d6ea0
some cleanup
anvacaru Oct 21, 2021
18f33b0
Merge remote-tracking branch 'origin/master' into midnight-test-runner
anvacaru Oct 21, 2021
4e51ed8
pyiele: fix coverage_timeout
anvacaru Oct 22, 2021
5eb5287
pyiele: add number of passing and failing tests
anvacaru Oct 25, 2021
8629b8c
Makefile: Add pyiele to package
gtrepta Oct 25, 2021
b8890c5
pyiele: Update wallet RPC calls for new interface
gtrepta Oct 26, 2021
28b95b3
pyiele/rpc.py: Handle rpc messages in a more structural way
gtrepta Oct 26, 2021
6f964f7
pyiele/testrunner.py: Fix qa_mineBlocks parameter
gtrepta Oct 26, 2021
0e25eac
move kiele-coverage in pyiele module
anvacaru Oct 27, 2021
93a252c
remove pyielerunner script
anvacaru Oct 27, 2021
cdf008e
Merge branch 'master' into midnight-test-runner
gtrepta Oct 27, 2021
89b4b47
Makefile: Add kieleCoverage.py to build
gtrepta Oct 27, 2021
bdb508c
Makefile: Fix removed files in python library
gtrepta Nov 1, 2021
3228ca1
pyiele: default values from config class
anvacaru Nov 2, 2021
b5720fe
Update Makefile
anvacaru Nov 3, 2021
cdd92fe
Update pyiele/__main__.py
anvacaru Nov 3, 2021
eea9f00
pyiele/blackbox: execute contracts once
anvacaru Nov 3, 2021
fdbc477
kieleCoverage: generate report for multiple contracts at once
anvacaru Nov 11, 2021
d49097f
pyiele: fix typo
anvacaru Nov 24, 2021
e9eb39b
Merge branch 'master' into midnight-test-runner
ehildenb Dec 1, 2021
d93fb17
kiele: Set PYTHONPATH for installed location
gtrepta Dec 1, 2021
d2a61c1
Merge branch 'master' into midnight-test-runner
anvacaru Dec 6, 2021
2ecfd1b
kiele: factor out listener check
anvacaru Dec 7, 2021
e9db650
kiele: refactor run_pyiele function
anvacaru Dec 7, 2021
465eaf3
kiele: remove redundant calls to pyiele help
anvacaru Dec 7, 2021
73f83a0
Update kiele
anvacaru Dec 7, 2021
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
44 changes: 29 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -405,19 +405,32 @@ coverage:
# Install
# -------

build: \
$(IELE_ASSEMBLE) \
$(IELE_CHECK) \
$(IELE_INTERPRETER) \
$(IELE_NODE) \
$(IELE_RUNNER) \
$(IELE_TEST_CLIENT) \
$(IELE_TEST_VM) \
$(IELE_VM) \
$(IELE_LIB)/kiele-generate-report.py \
$(IELE_LIB)/kore-json.py \
$(IELE_LIB)/static-report.html \
$(IELE_LIB)/version \
pyiele_files := pyiele/__init__.py \
pyiele/__main__.py \
pyiele/blackbox.py \
pyiele/config.py \
pyiele/fetchFunctionData.py \
pyiele/kieleCoverage.py \
pyiele/rlp.py \
pyiele/rpc.py \
pyiele/testrunner.py \
pyiele/transactionGeneration.py \
pyiele/utils.py

build: \
$(IELE_ASSEMBLE) \
$(IELE_CHECK) \
$(IELE_INTERPRETER) \
$(IELE_NODE) \
$(IELE_RUNNER) \
$(IELE_TEST_CLIENT) \
$(IELE_TEST_VM) \
$(IELE_VM) \
$(IELE_LIB)/kiele-generate-report.py \
$(IELE_LIB)/kore-json.py \
$(IELE_LIB)/static-report.html \
$(IELE_LIB)/version \
$(patsubst %, $(IELE_LIB)/%, $(pyiele_files)) \
$(haskell_kompiled)

all_bin_sources := $(shell find $(IELE_BIN) -type f \
Expand Down Expand Up @@ -471,8 +484,9 @@ install-vm: $(patsubst $(IELE_LIB)/%, $(DESTDIR)$(INSTALL_LIB)/%, $(IELE_VM))

install-check: $(patsubst %, $(DESTDIR)$(INSTALL_LIB)/%, $(iele_check_libs))

install-kiele: $(patsubst $(IELE_BIN)/%, $(DESTDIR)$(INSTALL_BIN)/%, $(IELE_RUNNER))
install-kiele: $(patsubst %, $(DESTDIR)$(INSTALL_LIB)/%, $(kiele_files))
install-kiele: $(patsubst $(IELE_BIN)/%, $(DESTDIR)$(INSTALL_BIN)/%, $(IELE_RUNNER)) \
$(patsubst %, $(DESTDIR)$(INSTALL_LIB)/%, $(kiele_files)) \
$(patsubst %, $(DESTDIR)$(INSTALL_LIB)/%, $(pyiele_files))

install: $(patsubst %, $(DESTDIR)$(INSTALL_BIN)/%, $(all_bin_sources)) \
$(patsubst %, $(DESTDIR)$(INSTALL_LIB)/%, $(all_lib_sources))
Expand Down
69 changes: 58 additions & 11 deletions kiele
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export PATH="${PATH}:${INSTALL_LIB}/standalone/iele-testing-kompiled"
export PATH="${PATH}:${INSTALL_LIB}/check/well-formedness-kompiled"
export PATH="${PATH}:${INSTALL_LIB}/node/iele-testing-kompiled"
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH:-}:/usr/local/lib
export PYTHONPATH=${PYTHONPATH:-}:"$(dirname $0)/../lib/kiele"

check_k_install() {
type -p kore-exec &> /dev/null \
Expand All @@ -26,6 +27,12 @@ check_k_install() {

check_token() { [ -v FIREFLY_TOKEN ] || fatal "FIREFLY_TOKEN environment variable isn't set!" ; }

check_listener() {
if ! nc -z "$kiele_host" "$kiele_port"; then
fatal "No listener found on port $kiele_port"
fi
}

make_temp_trap() {
local tmpdesc tmpfile
tmpdesc="$1" ; shift
Expand All @@ -47,6 +54,10 @@ run_assemble() {
iele-assemble "$run_file" "$@"
}

run_pyiele() {
python3 -m pyiele --host "$kiele_host" --port "$kiele_port" --output "$output_path" "$@"
}

run_interpret() {
local kast output status
kast=$(make_temp_trap kast)
Expand Down Expand Up @@ -111,20 +122,18 @@ run_vm() {
"${cmd[@]}"
}

run_coverage() {
notif "Generating coverage json from and client on port $kiele_port"
check_listener
run_pyiele coverage $@
}

run_generate_report() {
if [[ -f $(dirname $(which kiele))/static-report.html ]]; then
report_template=$(dirname $(which kiele))/static-report.html
else
report_template=$INSTALL_LIB/static-report.html
fi
output_path=""
while [[ $# -gt 0 ]]; do
arg="$1"
case $arg in
-o|--output) output_path="$2" ; shift 2 ;;
*) shift ;;
esac
done
kiele-generate-report.py "$report_template" "$run_file" "$output_path" "$create_archive"
}

Expand All @@ -141,6 +150,30 @@ run_upload_report() {
rm report.zip
}

run_compile() {
run_pyiele compile "$@"
}

run_testrunner() {
local run_file cmd
check_listener
cmd=(run_pyiele test)
if [[ $# -gt 0 ]] && ([[ -f "$1" ]] || [[ -d "$1" ]]); then
run_file="$1"; shift
if [[ "$run_file" == *.py ]]; then
cmd=(python3 "$run_file")
else
cmd+=(--file "$run_file")
fi
fi
"${cmd[@]}" "$@"
}

run_blackbox() {
check_listener
run_pyiele blackbox "$@"
}

# Main
# ----

Expand All @@ -153,8 +186,12 @@ if [[ "$run_command" == 'help' ]] || [[ "$run_command" == '--help' ]] ; then
$0 krun [--backend (standalone|haskell|node|check)] <KIELE arg>* <pgm> <K arg>*
$0 check <KIELE arg>* <pgm> <K arg>*
$0 vm <KIELE arg>*
$0 generate-report [--create-archive] <Report json path> [-o|--output <Report output path>]
$0 coverage <combined.json path> [-p|--port <client port>] [-o|--output <Report output path>]
$0 generate-report [--create-archive] <Report json path> [-o|--output <Report output path>]
$0 upload <Report json path>
$0 compile <COMPILE arg>*
$0 test <TEST arg>*
$0 blackbox <BLACKBOX arg>*

$0 [help|--help|version|--version]

Expand All @@ -163,9 +200,12 @@ if [[ "$run_command" == 'help' ]] || [[ "$run_command" == '--help' ]] ; then
$0 krun : Run given input <pgm> using 'krun'
$0 check : Run the IELE well-formedness checker on <pgm>
$0 vm : Run the KIELE VM server.
$0 coverage : Generates a report file containing contract information and coverage data.
$0 generate-report : Generate the static HTML report.
$0 upload : Upload the HTML report to the fireflyblockchain.com website.

$0 compile : Compile solidity contracts using isolc. If no path is provided, all the found .sol files will be compiled. For more information run 'kiele compile --help'.
$0 test : Runs either a python or a solidity test file. If no path is provided, will run all the tests found under the test folder. For more information run 'kiele test --help'.
$0 blackbox : Attempt to find new test inputs via blackbox random testing. For more information run 'kiele blackbox --help'.
$0 help : Display this help message.
$0 version : Display the versions of KIELE in use.

Expand All @@ -175,6 +215,7 @@ if [[ "$run_command" == 'help' ]] || [[ "$run_command" == '--help' ]] ; then
<K arg> is an argument you want to pass to K
<KIELE arg> is one of (--no-unparse|--debug|--host|--port|--mode|--coverage
|--schedule|--module|--definition|--depth)
<combined.json path> is the path to the build artifacts from 'isolc --combined-json'
<Report json path> is the path to the report json file
<Report output path> is the output HTML report file path (default: \$uuid.html)
"
Expand Down Expand Up @@ -202,6 +243,7 @@ depth=-1
args=()
create_archive='false'
parser='cat'
output_path='/dev/stdout'
while [[ $# -gt 0 ]]; do
arg="$1"
case $arg in
Expand All @@ -216,6 +258,7 @@ while [[ $# -gt 0 ]]; do
--coverage) enablecoverage='true' ; shift ;;
--create-archive) create_archive='true' ; shift ;;
--parser) parser="$2" ; shift 2 ;;
-o|--output) output_path="$2" ; shift 2 ;;
-p|--port) kiele_port="$2" ; shift 2 ;;
-h|--host) kiele_host="$2" ; shift 2 ;;
*) args+=("$1") ; shift ;;
Expand All @@ -233,7 +276,7 @@ cmode='Lbl'$mode'{}()'
cschedule='Lbl'$schedule'{}()'
cenablecoverage='\dv{SortBool{}}("'$enablecoverage'")'

if [[ "$run_command" != 'vm' ]]; then
if [[ "$run_command" != 'vm' ]] && [[ "$run_command" != 'coverage' ]] && [[ "$run_command" != 'compile' ]] && [[ "$run_command" != 'test' ]] && [[ "$run_command" != 'blackbox' ]]; then
run_file="$1" ; shift
[[ -f "$run_file" ]] || [[ "$run_file" == '-' ]] || fatal "File does not exist: $run_file"
fi
Expand All @@ -244,7 +287,11 @@ case "$run_command" in
krun) run_krun "$@" ;;
check) run_check "$@" ;;
vm) run_vm "$@" ;;
coverage) run_coverage "$@" ;;
generate-report) run_generate_report "$@" ;;
upload) run_upload_report "$@" ;;
compile) run_compile "$@" ;;
blackbox) run_blackbox "$@" ;;
test) run_testrunner "$@" ;;
*) $0 help ; fatal "Unknown command: $run_command" ;;
esac
11 changes: 11 additions & 0 deletions pyiele/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python3

from .config import *
from .rlp import *
from .rpc import *
from .fetchFunctionData import *
from .testrunner import *
from .utils import *
from .transactionGeneration import *
from .blackbox import *
from .kieleCoverage import *
Loading