diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..a1c6a7a9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +sudo: false +dist: trusty +language: python +cache: pip +python: + - '2.7' + - pypy-5.7.1 + +install: pip install .[pinq,js_snippets] + +script: + - | + if [[ "${TRAVIS_PYTHON_VERSION}" == "pypy"* ]]; then + python --jit disable_unrolling=0 run_tests.py + else + python run_tests.py + fi +matrix: + fast_finish: true diff --git a/macropy/core/test/exporters/__init__.py b/macropy/core/test/exporters/__init__.py index fd3116db..4a81e454 100644 --- a/macropy/core/test/exporters/__init__.py +++ b/macropy/core/test/exporters/__init__.py @@ -30,7 +30,7 @@ def test_pyc_exporter(self): # unless you touch the file to bring its mtime up to that of the # stored .pyc, in which case the macro gets re-run too - f = open(__file__ + "/../pyc_cache.py", "a") + f = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "pyc_cache.py"), "a") f.write(" ") f.close() @@ -40,7 +40,7 @@ def test_pyc_exporter(self): reload(pyc_cache) assert (pyc_cache_count, pyc_cache_macro_count) == (7, 4) - f = open(__file__ + "/../pyc_cache.py", "a") + f = open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "pyc_cache.py"), "a") f.write(" ") f.close() @@ -50,7 +50,7 @@ def test_pyc_exporter(self): def test_save_exporter(self): import macropy - macropy.exporter = SaveExporter(__file__ + "/../exported", __file__ + "/..") + macropy.exporter = SaveExporter(os.path.join(os.path.dirname(os.path.abspath(__file__)), "exported"), os.path.dirname(os.path.abspath(__file__))) # the original code should work import save @@ -62,4 +62,4 @@ def test_save_exporter(self): import macropy.core.test.exporters.exported.save as save_exported assert save_exported.run() == 14 import shutil - shutil.rmtree(__file__ + "/../exported") \ No newline at end of file + shutil.rmtree(os.path.join(os.path.dirname(os.path.abspath(__file__)), "exported")) diff --git a/macropy/core/test/exporters/pyc_cache.py b/macropy/core/test/exporters/pyc_cache.py index 1b43268f..d3df403b 100644 --- a/macropy/core/test/exporters/pyc_cache.py +++ b/macropy/core/test/exporters/pyc_cache.py @@ -2,4 +2,4 @@ from macropy.core.test import exporters exporters.pyc_cache_count += 1 -f[1] \ No newline at end of file +f[1] \ No newline at end of file diff --git a/macropy/experimental/test/__init__.py b/macropy/experimental/test/__init__.py index 2ee13aea..5b107871 100644 --- a/macropy/experimental/test/__init__.py +++ b/macropy/experimental/test/__init__.py @@ -2,13 +2,14 @@ #import js_snippets #import pattern #import pinq -import pyxl_snippets +cases = [] +try: + import pyxl +except ImportError: + pass +else: + import pyxl_snippets + cases.append(pyxl_snippets) #import tco_test -Tests = test_suite(cases = [ - #js_snippets, - #pattern, - #pinq, - pyxl_snippets, - #tco_test -]) \ No newline at end of file +Tests = test_suite(cases = cases) diff --git a/macropy/experimental/test/pyxl_snippets.py b/macropy/experimental/test/pyxl_snippets.py index 5864ddbe..73e0528f 100644 --- a/macropy/experimental/test/pyxl_snippets.py +++ b/macropy/experimental/test/pyxl_snippets.py @@ -94,6 +94,3 @@ def render(self): with require: normalize(pyxl_blob.to_string()) == normalize(target_blob) - - - diff --git a/macropy/test/peg.py b/macropy/test/peg.py index ec5f3823..3473b161 100644 --- a/macropy/test/peg.py +++ b/macropy/test/peg.py @@ -1,3 +1,4 @@ +import os import unittest from macropy.peg import macros, peg, Success, cut, ParseError @@ -369,7 +370,7 @@ def decode(x): if i not in [18]: # skipping the "too much nesting" failure test with self.assertRaises(ParseError): - json_doc.parse(open(__file__ + "/../peg_json/fail%s.json" % i).read()) + json_doc.parse(open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "peg_json/fail%s.json" % i)).read()) for i in [1, 2, 3]: - test(json_exp, open(__file__ + "/../peg_json/pass%s.json" % i).read()) + test(json_exp, open(os.path.join(os.path.dirname(os.path.abspath(__file__)), "peg_json/pass%s.json" % i)).read()) diff --git a/run_tests.py b/run_tests.py index 51ad8284..8b2e70b0 100644 --- a/run_tests.py +++ b/run_tests.py @@ -1,9 +1,11 @@ +import sys import unittest import macropy.activate import macropy.test -unittest.TextTestRunner().run(macropy.test.Tests) +result = unittest.TextTestRunner().run(macropy.test.Tests) +sys.exit(1 if result.errors or result.failures else 0)