Skip to content

Commit 5fb78e3

Browse files
authored
Added Travis tests (#15)
* added testing script * suppressed pyHyp output * Create .travis.yml * Update .travis.yml * updated file path * Update .travis.yml * Update .travis.yml * more path fixes * Update .travis.yml
1 parent d29715f commit 5fb78e3

File tree

2 files changed

+154
-0
lines changed

2 files changed

+154
-0
lines changed

.travis.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
os:
2+
- linux
3+
4+
language: generic
5+
6+
services:
7+
- docker
8+
env:
9+
global:
10+
- REPO_NAME=pyhyp
11+
- DOCKER_WORKING_DIR=/home/mdolabuser/repos/$REPO_NAME
12+
- DOCKER_MOUNT_DIR=/home/mdolabuser/travis/$REPO_NAME
13+
jobs:
14+
- DOCKER_TAG=py2-stable
15+
- DOCKER_TAG=py2-latest
16+
- DOCKER_TAG=py2-impi
17+
18+
before_install:
19+
- docker pull mdolab/public:$DOCKER_TAG
20+
# run Docker, key is we mount the current Travis directory into Docker to access content of repo
21+
- docker run -t -d
22+
--name app
23+
--mount "type=bind,src=$(pwd),target=$DOCKER_MOUNT_DIR"
24+
mdolab/public:$DOCKER_TAG
25+
/bin/bash
26+
27+
install:
28+
# We thrown away the existing repo in Docker, and copy the new one in-place
29+
- docker exec -it app /bin/bash -c "rm -rf $DOCKER_WORKING_DIR && cp -r $DOCKER_MOUNT_DIR $DOCKER_WORKING_DIR"
30+
- docker exec -it app /bin/bash -c ". \$HOME/.bashrc_mdolab && cd $DOCKER_WORKING_DIR && cp config/defaults/config.LINUX_GFORTRAN_OPENMPI.mk config/config.mk && sed -i 's/python3-config/python-config/g' config/config.mk && make"
31+
# the version of testflo is too new, we downgrade to the last version that supports py2
32+
- docker exec -it app /bin/bash -c ". \$HOME/.bashrc_mdolab && pip install testflo==1.3.5 "
33+
34+
script:
35+
# We need to source the mdolab bashrc before running anything
36+
- docker exec -it app /bin/bash -c ". \$HOME/.bashrc_mdolab && cd $DOCKER_WORKING_DIR && testflo . -v -n 1"
37+
# check that new CGNS files have been generated
38+
- docker exec -it app /bin/bash -c ". \$HOME/.bashrc_mdolab && cd $DOCKER_WORKING_DIR/python/examples && ls -l */*.cgns"
39+
40+
after_script:
41+
- docker rm -f app

python/reg_tests/test_all_examples.py

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
import os
2+
import subprocess
3+
import unittest
4+
import re
5+
import numpy as np
6+
from numpy.testing import assert_array_equal
7+
8+
baseDir = os.path.dirname(os.path.abspath(__file__))
9+
class TestExamples(unittest.TestCase):
10+
def common_test(self, test_dir, run_file, cgns_file, blocksizes_ref, info_ref):
11+
full_test_dir = os.path.abspath(os.path.join(baseDir, '../examples', test_dir))
12+
os.chdir(full_test_dir)
13+
subprocess.check_output(['python',run_file])
14+
self.check_cgns_utils('blockSizes', cgns_file, blocksizes_ref)
15+
self.check_cgns_utils('info', cgns_file, info_ref)
16+
os.chdir(baseDir)
17+
18+
def check_cgns_utils(self, cmd, cgns_file, ref):
19+
output = subprocess.check_output(['cgns_utils', cmd, cgns_file])
20+
output = str(output)
21+
numbers = np.array([int(i) for i in re.findall('\d+',output)])
22+
assert_array_equal(numbers, ref)
23+
24+
def test_2D_euler(self):
25+
test_dir = '2D'
26+
run_file = 'naca0012_euler.py'
27+
cgns_file = 'naca0012_euler.cgns'
28+
blocksizes_ref = [1, 32768, 66306, 257, 2, 129, 1, 32768, 66306]
29+
info_ref = [1, 32768, 66306, 256, 514]
30+
self.common_test(test_dir, run_file, cgns_file, blocksizes_ref, info_ref)
31+
32+
def test_2D_rans(self):
33+
test_dir = '2D'
34+
run_file = 'naca0012_rans.py'
35+
cgns_file = 'naca0012_rans.cgns'
36+
blocksizes_ref = [1, 38784, 78432, 304, 2, 129, 1, 38784, 78432]
37+
info_ref = [1, 38784, 78432, 303, 608]
38+
self.common_test(test_dir, run_file, cgns_file, blocksizes_ref, info_ref)
39+
40+
def test_717(self):
41+
test_dir = '717'
42+
run_file = 'run717.py'
43+
cgns_file = '717.cgns'
44+
blocksizes_ref = [1, 414720, 431649, 73, 73, 81, 2, 46080, 53217,
45+
9, 73, 81, 3, 414720, 431649, 73, 73, 81,
46+
4, 46080, 53217, 9, 73, 81, 5, 46080, 53217,
47+
9, 73, 81, 5, 967680, 1022949]
48+
info_ref = [5, 967680, 1022949, 12096, 12629]
49+
self.common_test(test_dir, run_file, cgns_file, blocksizes_ref, info_ref)
50+
51+
def test_BWB(self):
52+
test_dir = 'BWB'
53+
run_file = 'runBWB.py'
54+
cgns_file = 'bwb.cgns'
55+
blocksizes_ref = [1, 20480, 24057, 33, 9, 81, 2, 184320, 195129,
56+
73, 33, 81, 3, 20480, 24057, 9, 33, 81,
57+
4, 184320, 195129, 33, 73, 81, 5, 46080, 53217,
58+
73, 9, 81, 6, 30720, 35721, 49, 9, 81,
59+
7, 276480, 289737, 73, 49, 81, 8, 30720, 35721,
60+
9, 49, 81, 9, 276480, 289737, 49, 73, 81,
61+
9, 1070080, 1142505]
62+
info_ref = [9, 1070080, 1142505, 13376, 14105]
63+
self.common_test(test_dir, run_file, cgns_file, blocksizes_ref, info_ref)
64+
65+
def test_corner(self):
66+
test_dir = 'corner'
67+
run_file = 'runCorner.py'
68+
cgns_file = 'combined.cgns'
69+
blocksizes_ref = [1, 14400, 16640, 16, 16, 65, 2, 14400, 16640, 16, 16, 65,
70+
3, 14400, 16640, 16, 16, 65, 4, 14400, 16640, 16, 16, 65, 4, 57600, 66560]
71+
info_ref = [4, 57600, 66560, 900, 1024]
72+
self.common_test(test_dir, run_file, cgns_file, blocksizes_ref, info_ref)
73+
74+
def test_M6(self):
75+
test_dir = 'm6'
76+
run_file = 'runM6.py'
77+
cgns_file = 'm6.cgns'
78+
blocksizes_ref = [1, 81920, 89505, 65, 17, 81, 2, 368640, 384345,
79+
73, 65, 81, 3, 81920, 89505, 17, 65, 81,
80+
4, 368640, 384345, 65, 73, 81, 5, 92160, 100521,
81+
73, 17, 81, 6, 92160, 100521, 17, 73, 81,
82+
7, 20480, 23409, 17, 17, 81, 8, 20480, 23409,
83+
17, 17, 81, 9, 92160, 100521, 73, 17, 81,
84+
9, 1218560, 1296081]
85+
info_ref = [9, 1218560, 1296081, 15232, 16001]
86+
self.common_test(test_dir, run_file, cgns_file, blocksizes_ref, info_ref)
87+
88+
def test_plate(self):
89+
test_dir = 'plate'
90+
run_file = 'runPlate.py'
91+
cgns_file = 'face3D.cgns'
92+
blocksizes_ref = [1, 16384, 18785, 17, 17, 65, 1, 16384, 18785]
93+
info_ref = [1, 16384, 18785, 256, 289]
94+
self.common_test(test_dir, run_file, cgns_file, blocksizes_ref, info_ref)
95+
96+
def test_sphere(self):
97+
test_dir = 'sphere'
98+
run_file = 'runSphere.py'
99+
cgns_file = 'combined.cgns'
100+
blocksizes_ref = [1, 1152, 1825, 5, 5, 73, 2, 1152, 1825, 5,
101+
5, 73, 3, 1152, 1825, 5, 5, 73, 4, 1152,
102+
1825, 5, 5, 73, 5, 1152, 1825, 5, 5, 73,
103+
6, 1152, 1825, 5, 5, 73, 7, 18432, 21097, 17,
104+
17, 73, 8, 18432, 21097, 17, 17, 73, 9, 18432,
105+
21097, 17, 17, 73, 10, 18432, 21097, 17, 17, 73,
106+
11, 18432, 21097, 17, 17, 73, 12, 18432, 21097, 17,
107+
17, 73, 13, 73728, 79497, 33, 33, 73, 14, 73728,
108+
79497, 33, 33, 73, 15, 73728, 79497, 33, 33, 73,
109+
16, 73728, 79497, 33, 33, 73, 17, 73728, 79497, 33,
110+
33, 73, 18, 73728, 79497, 33, 33, 73, 18, 559872,
111+
614514]
112+
info_ref = [18, 559872, 614514, 7776, 8418]
113+
self.common_test(test_dir, run_file, cgns_file, blocksizes_ref, info_ref)

0 commit comments

Comments
 (0)