Skip to content

Commit

Permalink
Merge pull request #29714 from cticenhour/req-spec-multiple-29713
Browse files Browse the repository at this point in the history
Add capability to define multiple test spec file names in MooseDocs configurations
  • Loading branch information
cticenhour authored Jan 20, 2025
2 parents a27052f + 6c0e18d commit 4ac42ea
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 4 deletions.
4 changes: 4 additions & 0 deletions modules/doc/content/newsletter/2025/2025_01.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ for a complete description of all MOOSE changes.

## Bug Fixes and Minor Enhancements

- MooseDocs SQA has the ability to check against multiple test specification file names (for example, `tests` as well
as `assessments`) when performing requirement reporting and checks, using the `specs:` parameter
in `sqa_reports.yml`.

## Conda Package Changes
16 changes: 16 additions & 0 deletions modules/doc/training/content/sqa/training/lead/sqa_moosedocs.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ Requirements:
include_non_testable: true
```

Multiple test specifications files can be added (such as when `tests` and `assessments` are used as
filenames for organization) by setting the `specs:` parameter:

```
Requirements:
blackbear:
directories:
- test/tests
specs:
- tests
- assessments
log_testable: WARNING
show_warning: false
include_non_testable: true
```

!---

### SQA Reports: Running
Expand Down
7 changes: 4 additions & 3 deletions python/moosesqa/SQARequirementReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,11 @@ def execute(self, **kwargs):
raise NotADirectoryError("Supplied directory does not exist: {}".format(d))

# Build Requirement objects and remove directory based dict
req_dict = get_requirements_from_tests(directories, specs.split(), self.include_non_testable)
requirements = []
for values in req_dict.values():
requirements += values
for s in specs:
req_dict = get_requirements_from_tests(directories, s.split(), self.include_non_testable)
for values in req_dict.values():
requirements += values

# Populate the lists of tests for SQARequirementDiffReport
self.test_names = set()
Expand Down
8 changes: 8 additions & 0 deletions python/moosesqa/test/specs/spec_multiple
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# For testing mooseutils.sqa tools in the case that multiple specs are provided.
# This file is used in tandem with the spec_missing_req file in python/moosesqa/test/specs.
[Tests]
[no_issue]
design = 'design.md'
requirement = 'all'
[]
[]
17 changes: 16 additions & 1 deletion python/moosesqa/test/test_SQARequirementReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def testBasic(self, color_text):
@mock.patch('mooseutils.colorText', side_effect=lambda t, c, **kwargs: '{}:{}'.format(c,t))
def testOptions(self, *args):

reporter = SQARequirementReport(title='testing', specs='spec_missing_req',
# test single spec
reporter = SQARequirementReport(title='testing', specs=['spec_missing_req'],
directories=['python/moosesqa/test/specs'])
r = reporter.getReport()
self.assertEqual(reporter.status, SQAReport.Status.ERROR)
Expand All @@ -38,6 +39,20 @@ def testOptions(self, *args):
self.assertIn('log_empty_requirement: 1', r)
self.assertIn('log_empty_design: 1', r)
self.assertIn('log_empty_issues: 1',r )
self.assertIn('log_duplicate_requirement: 1', r)

# test multiple specs
reporter = SQARequirementReport(title='testing', specs=['spec_missing_req','spec_multiple'],
directories=['python/moosesqa/test/specs'])
r = reporter.getReport()
self.assertEqual(reporter.status, SQAReport.Status.ERROR)
self.assertIn('log_missing_requirement: 1', r)
self.assertIn('log_missing_design: 1', r)
self.assertIn('log_missing_issues: 2', r)
self.assertIn('log_empty_requirement: 1', r)
self.assertIn('log_empty_design: 1', r)
self.assertIn('log_empty_issues: 1',r )
self.assertIn('log_duplicate_requirement: 2', r)

if __name__ == '__main__':
unittest.main(verbosity=2)

0 comments on commit 4ac42ea

Please sign in to comment.