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 3e6cfa5
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/tests/misc/hit_cli/gold/additional_pattern
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
input1.i:21 BCs/left/value = 0
1 match found.
4 changes: 4 additions & 0 deletions test/tests/misc/hit_cli/gold/additional_pattern_negative
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
input2.i:16 PostProcessor/max/value = 1
input2.i:21 PostProcessor/min/value = 1
input2.i:26 PostProcessor/min2/value = 1
3 matches found.
2 changes: 2 additions & 0 deletions test/tests/misc/hit_cli/gold/parameter_does_not_exist
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
input2.i
1 match found.
3 changes: 3 additions & 0 deletions test/tests/misc/hit_cli/gold/parameter_exists
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
input1.i:9 Kernels/diff_u/variable = u
input1.i:13 Kernels/diff_v/variable = v
2 matches found.
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
[]
[]
28 changes: 28 additions & 0 deletions test/tests/misc/hit_cli/input2.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.
#

[Outputs]
[out]
type = Exodus
[]
[]

[PostProcessor]
[max]
type = Calculation
mode = MAX
value = 1
[]
[min]
type = Calculation
mode = min
value = 1
[]
[min2]
type = Calculation
mode = MIN
value = 1
[]
[]
41 changes: 41 additions & 0 deletions test/tests/misc/hit_cli/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[Tests]
issues = '#19001'
design = 'hit.md'

[find]
requirement = 'The hit find command shall be able to find'
[parameter_exists]
type = RunCommand
command = './hit_wrapper.py gold/parameter_exists find Kernels/\*/variable input1.i input2.i'
detail = 'files with specific parameters,'
[]
[parameter_does_not_exist]
type = RunCommand
command = './hit_wrapper.py gold/parameter_does_not_exist find -v Kernels/\*/variable input1.i '
'input2.i'
detail = 'files not containing a specified parameter,'
[]

[positive_pattern]
type = RunCommand
command = './hit_wrapper.py gold/positive_pattern find Kernels/\*/variable=u input1.i'
detail = 'parameters set to an exact specified value,'
[]
[negative_pattern]
type = RunCommand
command = './hit_wrapper.py gold/positive_pattern find Kernels/\*/variable!=v input1.i'
detail = 'parameters not set to an exact specified value,'
[]

[additional_pattern]
type = RunCommand
command = './hit_wrapper.py gold/additional_pattern find -p type=DirichletBC -- \*/value input1.i input2.i'
detail = 'parameters with additional pattern constraints,'
[]
[additional_pattern_negative]
type = RunCommand
command = './hit_wrapper.py gold/additional_pattern_negative find -p type!=DirichletBC -- \*/value input1.i input2.i'
detail = 'parameters with additional pattern constraints,'
[]
[]
[]

0 comments on commit 3e6cfa5

Please sign in to comment.