Skip to content

Commit

Permalink
Add tests (idaholab#19001)
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Oct 18, 2021
1 parent 82f6f72 commit 787f09c
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/tests/misc/hit_cli/gold/positive_pattern
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
input1.i:9 Kernels/diff_u/variable = u
1 match found.
28 changes: 28 additions & 0 deletions test/tests/misc/hit_cli/hit_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3

import sys
import os
import subprocess

if len(sys.argv) < 2:
print("Usage:\nhit_wrapper.py gold_output [hit arguments]\n")

MOOSE_DIR = os.getenv('MOOSE_DIR', os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', '..', '..')))
hit = os.path.join(MOOSE_DIR, 'framework', 'contrib', 'hit', 'hit')
if not os.path.exists(hit):
print('Failed to locate hit executable.')
sys.exit(1)

gold_file = sys.argv[1]
hit_args = sys.argv[2:]

with open(gold_file, 'rb') as f:
gold = f.read()

out = subprocess.check_output([hit] + hit_args)

if out == gold:
sys.exit(0)

print("Output:\n", out, "\ndoes not match gold:\n", gold)
sys.exit(1)
28 changes: 28 additions & 0 deletions test/tests/misc/hit_cli/input1.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# This is not a valid MOOSE input, it is only used for testing the HIT command
# line utility.
#

[Kernels]
[diff_u]
type = Diffusion
variable = u
[]
[diff_v]
type = Diffusion
variable = v
[]
[]

[BCs]
[left]
type = DirichletBC
variable = u
value = 0
[]
[right]
type = NeumannBC
variable = v
value = 0
[]
[]
10 changes: 10 additions & 0 deletions test/tests/misc/hit_cli/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Tests]
[positive_pattern]
type = RunCommand
command = ./hit_wrapper.py gold/positive_pattern find Kernels/\*/variable=u input1.i'
[]
[negative_pattern]
type = RunCommand
command = ./hit_wrapper.py gold/positive_pattern find Kernels/\*/variable!=v input1.i'
[]
[]

0 comments on commit 787f09c

Please sign in to comment.