ffc team mailing list archive
-
ffc team
-
Mailing list archive
-
Message #02012
Patch for test scripts
Hi,
Please apply the attached patch which makes the test scripts more
cross-platform friendly.
Johannes
# HG changeset patch
# User Johannes Ring <johannr@xxxxxxxxx>
# Date 1230546676 -3600
# Node ID 6ff41f02b0b8e20a45ca789aa4c5ecab18dc29ac
# Parent ed8b2a6e79710ddc6966b036c6e78c6beef4cdbb
Cross-platform fixes for test scripts.
diff -r ed8b2a6e7971 -r 6ff41f02b0b8 test/regression/test.py
--- a/test/regression/test.py Thu Dec 11 14:02:38 2008 +0100
+++ b/test/regression/test.py Mon Dec 29 11:31:16 2008 +0100
@@ -6,7 +6,7 @@
__license__ = "GNU GPL version 3 or any later version"
import sys
-from os import chdir, listdir, system
+from os import chdir, listdir, system, path, pardir, curdir
from difflib import unified_diff
# Check arguments, -nw specifices that we run in terminal mode
@@ -16,8 +16,8 @@
nw = False
# Check all in demo directory
-chdir("../../demo")
-form_files = [f for f in listdir(".") if f[-5:] == ".form"]
+chdir(path.join(pardir, pardir, "demo"))
+form_files = [f for f in listdir(curdir) if f[-5:] == ".form"]
form_files.sort()
num_forms = len(form_files)
num_forms_ok = 0
@@ -29,11 +29,11 @@
print "Compiling and verifying form %s..." % form_file
# Compile form
- if system("../scripts/ffc -fprecision=9 -s %s" % form_file) == 0:
+ if system("python %s -fprecision=9 -s %s" % (path.join(pardir, "scripts", "ffc"), form_file)) == 0:
# Compare against reference
code_file = form_file.split(".")[0] + ".h"
- f0 = open("../test/regression/reference/%s" % code_file, "r")
+ f0 = open(path.join(pardir, "test", "regression", "reference", code_file), "r")
f1 = open(code_file, "r")
c0 = f0.read().split("\n")
c1 = f1.read().split("\n")
diff -r ed8b2a6e7971 -r 6ff41f02b0b8 test/test.py
--- a/test/test.py Thu Dec 11 14:02:38 2008 +0100
+++ b/test/test.py Mon Dec 29 11:31:16 2008 +0100
@@ -5,9 +5,10 @@
__copyright__ = "Copyright (C) 2007 Anders Logg"
__license__ = "GNU GPL version 3 or any later version"
-from os import system
-from commands import getoutput
+import os
import re
+
+pwd = os.path.dirname(os.path.abspath(__file__))
# Tests to run
tests = ["unit", "regression"]
@@ -16,5 +17,6 @@
for test in tests:
print "Running tests: %s" % test
print "----------------------------------------------------------------------"
- system("cd %s; python test.py" % test)
+ os.chdir(os.path.join(pwd, test))
+ os.system("python test.py")
print ""
diff -r ed8b2a6e7971 -r 6ff41f02b0b8 test/unit/test.py
--- a/test/unit/test.py Thu Dec 11 14:02:38 2008 +0100
+++ b/test/unit/test.py Mon Dec 29 11:31:16 2008 +0100
@@ -9,8 +9,9 @@
import sys
import numpy
import math
+import os
-sys.path.append("../..")
+sys.path.append(os.path.join(os.pardir, os.pardir))
from ffc import *
triangle = [(0, 0), (1, 0), (0, 1)]
Follow ups