Skip to content

Commit

Permalink
Move testing to unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Strange committed Jul 7, 2019
1 parent 4a5ce40 commit 88ee237
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ python:
- "3.7"
install: "pip3 install -r requirements.txt"
script:
- python3 test.py
- python3 ./tests/basicparsing/nominal.py
- python3 ./tests/backend/paraloop.py
18 changes: 0 additions & 18 deletions test.py

This file was deleted.

3 changes: 3 additions & 0 deletions tests/backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Backend

This folder contains tests for the back-end.
13 changes: 9 additions & 4 deletions testmodule.py → tests/backend/othersrc.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
"""
This is a module.
Another source code module for testing.
"""
import acc.api as pyacc
import math as mat
import os
import sys

mydir = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.abspath(os.path.join(mydir, "../..")))
import acc.api as openacc

def modules_local_function(nothing):
print("This module is a hoax!")
pass

@pyacc.acc()
@openacc.acc()
def square(ls):
"""
This is the test function's doc string. This function's got lots going on
Expand Down
20 changes: 20 additions & 0 deletions tests/backend/paraloop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
This module contains all the tests for the Parallel-Loop hybrid construct.
"""
import src
import unittest

class TestParalellLoop(unittest.TestCase):
def test_nominal(self):
"""
Test the nominal use of a parallel loop.
"""
sqrd = src.test_function()
expected = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
self.assertEqual(len(sqrd), len(expected))

for i, (s, e) in enumerate(zip(sqrd, expected)):
self.assertEqual(s, e, "sqrd[{}] should equal expected[{}], but {} != {}".format(i, i, s, e))

if __name__ == "__main__":
unittest.main()
15 changes: 15 additions & 0 deletions tests/backend/src.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
This is source code for the tests in this module.
"""
import os
import sys
import othersrc

def _a_local_function(some_args):
print("Does nothing")
return None

def test_function():
ls = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
squares = othersrc.square(ls)
return squares
8 changes: 8 additions & 0 deletions tests/basicparsing/nominal.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ def no_pragmas1():
"""
pass

@openacc.acc()
def no_pragmas2():
"""
Another docstring.
"""
return 5 + 5

####################################################################################
###################### ACTUAL TESTS ################################################
####################################################################################
Expand All @@ -36,6 +43,7 @@ def test_no_pragmas(self):
# Simple crash tests
no_pragmas0()
no_pragmas1()
no_pragmas2()

if __name__ == "__main__":
unittest.main()

0 comments on commit 88ee237

Please sign in to comment.