Skip to content
Closed
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
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exclude: configure|\.*.msh|\.*.rng|^h5hut/\.*|^libjudy\.*|^libmba2d\.*|^libmba3d\.*|^libspud\.*|^spatialindex-1.8.0\.*
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: check-ast
- id: check-builtin-literals
Expand All @@ -19,12 +19,12 @@ repos:
- id: mixed-line-ending
exclude: ref_vtk_hexahedra.vtu
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.5.1
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 9.0.0b5
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
Expand All @@ -33,7 +33,7 @@ repos:
hooks:
- id: pyupgrade
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.3.0
hooks:
- id: flake8
args: ["--max-line-length", "88", "--extend-ignore", "E203,E722"]
12 changes: 6 additions & 6 deletions examples/driven_cavity/driven_cavity.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def erturk_u(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape
norm = 0.0
for i in range(ilen):
diff = pts[i][3] - velocity[i][0]
Expand Down Expand Up @@ -217,7 +217,7 @@ def erturk_v(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape
norm = 0.0
for i in range(ilen):
diff = pts[i][3] - velocity[i][1]
Expand Down Expand Up @@ -269,7 +269,7 @@ def botella_u(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape
norm = 0.0
for i in range(ilen):
diff = pts[i][3] - velocity[i][0]
Expand Down Expand Up @@ -320,7 +320,7 @@ def botella_v(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape

norm = 0.0
for i in range(ilen):
Expand Down Expand Up @@ -372,7 +372,7 @@ def botella_p1(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape
pressure = u.ProbeData(pts, "Pressure")

pts0 = np.array(
Expand Down Expand Up @@ -430,7 +430,7 @@ def botella_p2(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape
pressure = u.ProbeData(pts, "Pressure")

pts0 = np.array(
Expand Down
2 changes: 1 addition & 1 deletion examples/driven_cavity/generate_mesh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ optparser = OptionParser(
description="""Generate the mesh files for a given resolution.""",
)

(options, argv) = optparser.parse_args()
options, argv = optparser.parse_args()

try:
NN = int(argv[0])
Expand Down
6 changes: 2 additions & 4 deletions examples/driven_cavity/plot_data
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import pylab


def usage():
print(
"""plot_data <NN>
print("""plot_data <NN>

<NN> is a space-separated list of the inverse mesh spacing."""
)
<NN> is a space-separated list of the inverse mesh spacing.""")


try:
Expand Down
84 changes: 74 additions & 10 deletions tools/unittestharness.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ def display_results(tests_results, error_list, skip_list):
)


def unittest_harness_no_output(tests):
def unittest_harness_no_output(tests, quiet=False):
tests_results = {"Pass": Counter(), "Warn": Counter(), "Fail": Counter()}
error_list, skip_list = [], []
dot_count = 0

for test in tests:
print(f"\t-> New test: {test.name}")
if not quiet:
print(f"\t-> New test: {test.name}")

if (tests_dir / test.name).is_file() is False:
print(f"WARNING: {test.name} not found")
Expand All @@ -64,25 +66,54 @@ def unittest_harness_no_output(tests):
error_list.append(test.name)
continue

non_pass_output = []
has_failure = False
for test_output in test_proc.stdout.splitlines():
try:
tests_results[test_output[:4]][test.name] += 1
except KeyError:
print(f"\t\t\t{test_output.lstrip()}")
if not quiet:
print(f"\t\t\t{test_output.lstrip()}")
continue

print(f"\t\t{test_output}")
if test_output[:4] in ("Warn", "Fail"):
has_failure = True
non_pass_output.append(test_output)

if not quiet:
print(f"\t\t{test_output}")

if quiet and has_failure:
if dot_count:
print()
dot_count = 0
print(f"\t-> Failed test: {test.name}")
for output_line in non_pass_output:
print(f"\t\t{output_line}")
if test_proc.stderr:
print(f"\t\tStderr output: {test_proc.stderr}")
elif quiet:
print(".", end="", flush=True)
dot_count += 1
if dot_count == 80:
print()
dot_count = 0

if quiet and dot_count:
print()

display_results(tests_results, error_list, skip_list)


def unittest_harness(tests, xml_outfile):
def unittest_harness(tests, xml_outfile, quiet=False):
xml_parser = TestSuite("unittest_harness")
tests_results = {"Pass": Counter(), "Warn": Counter(), "Fail": Counter()}
error_list, skip_list = [], []
dot_count = 0

for test in tests:
print(f"\t-> New test: {test.name}")
if not quiet:
print(f"\t-> New test: {test.name}")

if (tests_dir / test.name).is_file() is False:
print(f"WARNING: {test.name} not found")
Expand Down Expand Up @@ -125,15 +156,23 @@ def unittest_harness(tests, xml_outfile):
continue

other_out = ""
non_pass_output = []
has_failure = False
for test_output in test_proc.stdout.splitlines():
try:
tests_results[test_output[:4]][test.name] += 1
except KeyError:
print(f"\t\t\t{test_output.lstrip()}")
if not quiet:
print(f"\t\t\t{test_output.lstrip()}")
other_out += test_output.lstrip() + "\n"
continue

print(f"\t\t{test_output}")
if test_output[:4] in ("Warn", "Fail"):
has_failure = True
non_pass_output.append(test_output)

if not quiet:
print(f"\t\t{test_output}")

try:
# Look for the test output message enclosed between brackets
Expand Down Expand Up @@ -172,6 +211,25 @@ def unittest_harness(tests, xml_outfile):

xml_parser.test_cases.append(xml_entry)

if quiet and has_failure:
if dot_count:
print()
dot_count = 0
print(f"\t-> Failed test: {test.name}")
for output_line in non_pass_output:
print(f"\t\t{output_line}")
if test_proc.stderr:
print(f"\t\tStderr output: {test_proc.stderr}")
elif quiet:
print(".", end="", flush=True)
dot_count += 1
if dot_count == 80:
print()
dot_count = 0

if quiet and dot_count:
print()

display_results(tests_results, error_list, skip_list)

with open(xml_outfile, "w") as fid:
Expand Down Expand Up @@ -223,6 +281,12 @@ def add_path_to_environment_variable(env_var, env_path):
help="remove the directory provided through --dir",
)
parser.add_argument("--efence", action="store_true", help="links against libefence")
parser.add_argument(
"-q",
"--quiet",
action="store_true",
help="only print diagnostics for failing tests",
)
args = parser.parse_args()

fluidity_root = Path(sys.argv[0]).resolve().parent.parent
Expand Down Expand Up @@ -261,6 +325,6 @@ def add_path_to_environment_variable(env_var, env_path):
assert (
float(get_distribution("junit_xml").version) >= 1.9
), "Please update junit_xml"
unittest_harness(tests, args.xml_output)
unittest_harness(tests, args.xml_output, args.quiet)
else:
unittest_harness_no_output(tests)
unittest_harness_no_output(tests, args.quiet)
Loading