Skip to content
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
22 changes: 22 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and Test

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-20.04
env:
BOOST_LIBDIR: /usr/lib/x86_64-linux-gnu/
steps:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y --no-install-recommends --no-install-suggests g++ python-dev python3-dev python3-pip maven libnuma-dev libc-dev python3-venv openmpi-bin libopenmpi-dev flex bison libomp-dev gsl-bin libgsl0-dev libboost-all-dev imagemagick-6.q16 inkscape
- name: build cpp
run: make all
- name: test
run: cd bin && ./test.sh
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ pip install pypng
pip install pytest
pip install matplotlib
pip install ipywidgets
pip install pandas
jupyter nbextension enable --py widgetsnbextension

export ENVIRON_CONFIG_DIRS=","
export PATH=$PATH:$PWD
pytest test || exit 1

88 changes: 88 additions & 0 deletions bin/test/integration_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import pytest
import subprocess
import sys
import threading
import pandas as pd
import math

def exec_command(command, cwd=None):
process = subprocess.Popen(command,
stdout=subprocess.PIPE,
universal_newlines=True)
while True:
output = process.stdout.readline()
print(output.strip())
# Do something else
return_code = process.poll()
if return_code is not None:
print('RETURN CODE', return_code)
# Process has finished, read rest of the output
for output in process.stdout.readlines():
print(output.strip())
break


def test_example_one():
command = "np_shape_lab -R 10 -q 600 -c 0.005 -t 1 -v 1 -b 40 -s 40 -S 25000 -D 4 -F n"
command_list = command.split();
exec_command(command_list, cwd="..")
df = pd.read_csv('outfiles/area.dat', sep=r"\s+", header=None)
t = df.iat[-1, 1]
assert math.isclose(t, 15.675, rel_tol=1e-1)

df = pd.read_csv('outfiles/energy_in_parts_kE_bE_sE_tE_ljE_esE.dat', sep=r"\s+", header=None)
t = df.iat[-1, 4]
assert math.isclose(t, 380.971, rel_tol=1e-1)


def test_example_two():
command = "np_shape_lab -R 10 -q 600 -c 0.01 -t 1 -v 1 -b 40 -s 40 -S 25000 -D 4 -F n"
command_list = command.split();
exec_command(command_list, cwd="..")
df = pd.read_csv('outfiles/area.dat', sep=r"\s+", header=None)
t = df.iat[-1, 1]
assert math.isclose(t, 13.2595, rel_tol=1e-2)

df = pd.read_csv('outfiles/energy_in_parts_kE_bE_sE_tE_ljE_esE.dat', sep=r"\s+", header=None)
t = df.iat[-1, 4]
assert math.isclose(t, 322.264, rel_tol=1e-1)


def test_example_three():
command = "np_shape_lab -R 10 -q 600 -N 2 -p 0.5 -c 0.005 -t 1 -v 1 -b 40 -s 40 -S 25000 -D 4 -F n"
command_list = command.split();
exec_command(command_list, cwd="..")
df = pd.read_csv('outfiles/area.dat', sep=r"\s+", header=None)
t = df.iat[-1, 1]
assert math.isclose(t, 12.5275, rel_tol=1e-2)

df = pd.read_csv('outfiles/energy_in_parts_kE_bE_sE_tE_ljE_esE.dat', sep=r"\s+", header=None)
t = df.iat[-1, 4]
assert math.isclose(t, 304.473, rel_tol=1e-1)


def test_example_four():
command = "np_shape_lab -R 10 -q 0 -c 0.005 -t 0 -v 0 -b 1 -s 1000 -S 25000 -D 4 -F n -B y"
command_list = command.split();
exec_command(command_list, cwd="..")
df = pd.read_csv('outfiles/area.dat', sep=r"\s+", header=None)
t = df.iat[-1, 1]
assert math.isclose(t, 12.3795, rel_tol=1e-2)

df = pd.read_csv('outfiles/energy_in_parts_kE_bE_sE_tE_ljE_esE.dat', sep=r"\s+", header=None)
t = df.iat[-1, 3]
assert math.isclose(t, 5.87409, rel_tol=1e-1)

def test_example_five():
command = "np_shape_lab -R 10 -q 600 -N 2 -p 0.5 -c 0.005 -t 1 -v 1 -b 40 -s 40 -S 25000 -D 4 -F n -H y"
command_list = command.split();
exec_command(command_list, cwd="..")
df = pd.read_csv('outfiles/area.dat', sep=r"\s+", header=None)
t = df.iat[-1, 1]
assert math.isclose(t, 12.5099, rel_tol=1e-2)

df = pd.read_csv('outfiles/energy_in_parts_kE_bE_sE_tE_ljE_esE.dat', sep=r"\s+", header=None)
t = df.iat[-1, 4]
assert math.isclose(t, 304.044, rel_tol=1e-1)


25 changes: 24 additions & 1 deletion bin/test/npshape_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import testbook
import os
import os, shutil
import svgwrite
import png

Expand Down Expand Up @@ -32,3 +32,26 @@ def test_convert_SVG_PNG(tb):
assert os.path.exists("test/resources/output.png") == 1
os.remove("test/resources/output.png")

#@testbook.testbook('npshape-frontend.ipynb', execute=True)
#def test_create_out_dirs(tb):
# func = tb.ref("createOutDirs")
# func()
# assert os.path.exists("outfiles")
# assert os.path.exists("simulation_snapshots")
# assert os.path.exists("snapshot_png")
# shutil.rmtree('outfiles', True)
# shutil.rmtree('simulation_snapshots', True)
# shutil.rmtree('snapshot_png', True)

#@testbook.testbook('npshape-frontend.ipynb', execute=True)
#def test_paramerter_append(tb):
# func = tb.ref("appendParameters")
# params = 'Maximum Surface Charge(Q in e) is 1\nNumber of patches used: 1\n' \
# 'Patch size (p) is 1\nSurface Charge(Q in e) is 1\nBending Modulus is ' \
# '1\nStretching Modulus is 1\nSalt Concentration (M) is 1\n'
# out = func(1, 1, 1, 1, 1, 1, 1, 4)
# assert params == out