def testBasic(self):
        MOOSE_DIR = os.path.abspath(
            os.path.join(os.path.dirname(__file__), '..', '..', '..'))
        loc = [os.path.join(MOOSE_DIR, 'test', 'tests', 'markers')]
        req = get_requirements(loc, ['tests'])

        r0 = req['box_marker'][0]
        r1 = req['box_marker'][1]

        self.assertEqual(r0.issues, ['#1275'])
        self.assertEqual(r1.issues, ['#1275'])

        self.assertEqual(r0.design, ['/Markers/index.md', '/BoxMarker.md'])
        self.assertEqual(r1.design, ['/Markers/index.md', '/BoxMarker.md'])

        self.assertIn('create an aux', r0.requirement)
        self.assertIn('within a rec', r1.requirement)

        self.assertEqual(r0.name, 'mark_only')
        self.assertEqual(r1.name, 'mark_and_adapt')

        self.assertEqual(r0.path, 'box_marker')
        self.assertEqual(r1.path, 'box_marker')

        self.assertIn('markers/box_marker/tests', r0.filename)
        self.assertIn('markers/box_marker/tests', r1.filename)
Exemple #2
0
    def preExecute(self):
        """Initialize requirement information"""

        # Clear any existing counts
        self.__counts.clear()

        # Do not repopulate
        if self.__requirements:
            return

        start = time.time()
        LOG.info("Gathering SQA requirement information...")

        repos = self.get('repos')
        for index, (category,
                    info) in enumerate(self.get('categories').items(), 1):
            specs = info.get('specs', ['tests'])
            repo = info.get('repo', 'default')
            reports = info.get('reports', None)
            directories = []

            for d in info.get('directories'):
                path = mooseutils.eval_path(d)
                if not os.path.isdir(path):
                    path = os.path.join(MooseDocs.ROOT_DIR, d)
                if not os.path.isdir(path):
                    msg = "Input directory does not exist: %s"
                    LOG.error(msg, path)

                directories.append(path)

            # Create requirement database
            self.__requirements[category] = moosesqa.get_requirements(
                directories, specs, 'F', index)

            # Create dependency database
            self.__dependencies[category] = info.get('dependencies', [])

            # Create remote repository database
            self.__remotes[category] = repos.get(repo, None)

            # Create reports from included SQA apps (e.g., moose/modulus/stochastic_tools)
            if reports:
                self.__reports[category] = moosesqa.get_sqa_reports(reports)

        # Report for the entire app (e.g, moose/modules/doc)
        general_reports = self.get('reports')
        if general_reports is not None:
            self.__reports['__empty__'] = moosesqa.get_sqa_reports(
                general_reports)

        # The following attempts to save computation time by avoiding re-computing the application
        # syntax for each report. This is done by extracting the syntax from the appsyntax extension
        # and using it within the SQAMooseAppReport objects.

        # Get the syntax tree and executable info from the appsyntax extension
        app_syntax = None
        exe_dir = None
        exe_name = None
        for ext in self.translator.extensions:
            if isinstance(ext, appsyntax.AppSyntaxExtension):
                app_syntax = ext.syntax
                exe_dir, exe_name = os.path.split(
                    ext.executable) if ext.executable else (None, None)
                break

        # Setup the SQAMooseAppReports to use the syntax from the running app
        for reports in self.__reports.values():
            for app_report in reports[2]:
                app_report.app_syntax = app_syntax
                app_report.exe_directory = exe_dir
                app_report.exe_name = exe_name.split(
                    '-')[0] if exe_name else None
                if app_syntax is None:
                    msg = 'Attempting to inject application syntax into SQAMooseAppReport, but the syntax does not exist.'
                    LOG.warning(msg)

        # Add RunException tests to FAILURE_ANALYSIS collection
        for req_category in self.__requirements.values():
            for requirements in req_category.values():
                for req in requirements:
                    t_types = req.types
                    if (req.collections is
                            None) and (t_types is not None) and ('RunException'
                                                                 in t_types):
                        req.collections = set(['FAILURE_ANALYSIS'])

        LOG.info("Gathering SQA requirement information complete [%s sec.]",
                 time.time() - start)
    def testRequirementWithDetails(self):
        loc = [os.getcwd()]
        req = get_requirements(loc, ['test_get_requirements_spec0'])

        self.assertEqual(len(req), 1)
        self.assertEqual(len(req['test_get_requirements_spec0']), 9)

        r = req['test_get_requirements_spec0'][0]
        self.assertEqual(r.issues, ['#1234'])
        self.assertEqual(r.design, ['core.md'])
        self.assertEqual(r.requirement, "Requirement One")

        r = req['test_get_requirements_spec0'][1]
        self.assertEqual(r.issues, ['#3456'])
        self.assertEqual(r.design, ['core.md'])
        self.assertEqual(r.requirement, "Requirement Two")

        r = req['test_get_requirements_spec0'][2]
        self.assertEqual(r.issues, ['#1234'])
        self.assertEqual(r.design, ['bibtex.md'])
        self.assertEqual(r.requirement, "Requirement Three")

        r = req['test_get_requirements_spec0'][3]
        self.assertEqual(r.issues, ['#4567'])
        self.assertEqual(r.design, ['katex.md'])
        self.assertEqual(r.requirement, "Requirement Four")

        r = req['test_get_requirements_spec0'][4]
        self.assertEqual(r.issues, ['#1234'])
        self.assertEqual(r.design, ['core.md'])
        self.assertEqual(r.requirement, "Requirement Group One")
        self.assertEqual(len(r.details), 2)

        d = r.details[0]
        self.assertEqual(d.name, 'group0-a')
        self.assertEqual(d.detail, '1D')
        self.assertEqual(d.detail_line, 27)

        d = r.details[1]
        self.assertEqual(d.name, 'group0-b')
        self.assertEqual(d.detail, '2D')
        self.assertEqual(d.detail_line, 30)

        r = req['test_get_requirements_spec0'][5]
        self.assertEqual(r.issues, ['#8910'])
        self.assertEqual(r.design, ['core.md'])
        self.assertEqual(r.requirement, "Requirement Group Two")
        self.assertEqual(len(r.details), 2)

        d = r.details[0]
        self.assertEqual(d.name, 'group1-a')
        self.assertEqual(d.detail, '3D')
        self.assertEqual(d.detail_line, 38)

        d = r.details[1]
        self.assertEqual(d.name, 'group1-b')
        self.assertEqual(d.detail, '4D')
        self.assertEqual(d.detail_line, 41)

        r = req['test_get_requirements_spec0'][6]
        self.assertEqual(r.issues, ['#1234'])
        self.assertEqual(r.design, ['bibtex.md'])
        self.assertEqual(r.requirement, "Requirement Group Three")
        self.assertEqual(len(r.details), 2)

        d = r.details[0]
        self.assertEqual(d.name, 'group2-a')
        self.assertEqual(d.detail, '5D')
        self.assertEqual(d.detail_line, 50)

        d = r.details[1]
        self.assertEqual(d.name, 'group2-b')
        self.assertEqual(d.detail, '6D')
        self.assertEqual(d.detail_line, 53)

        r = req['test_get_requirements_spec0'][7]
        self.assertEqual(r.issues, ['#4321'])
        self.assertEqual(r.design, ['katex.md'])
        self.assertEqual(r.requirement, "Requirement Group Four")
        self.assertEqual(len(r.details), 2)

        d = r.details[0]
        self.assertEqual(d.name, 'group3-a')
        self.assertEqual(d.detail, '7D')
        self.assertEqual(d.detail_line, 62)

        d = r.details[1]
        self.assertEqual(d.name, 'group3-b')
        self.assertEqual(d.detail, '8D')
        self.assertEqual(d.detail_line, 65)
Exemple #4
0
    def testRequirementWithDetails(self):
        loc = [os.getcwd()]
        req = get_requirements(loc, ['test_get_requirements_spec0'])

        self.assertEqual(len(req), 1)
        self.assertEqual(len(req['test_get_requirements_spec0']), 19)

        r = req['test_get_requirements_spec0'][0]
        self.assertEqual(r.issues, ['#1234'])
        self.assertEqual(r.design, ['core.md'])
        self.assertEqual(r.requirement, "Requirement One")

        r = req['test_get_requirements_spec0'][1]
        self.assertEqual(r.issues, ['#3456'])
        self.assertEqual(r.design, ['core.md'])
        self.assertEqual(r.requirement, "Requirement Two")

        r = req['test_get_requirements_spec0'][2]
        self.assertEqual(r.issues, ['#1234'])
        self.assertEqual(r.design, ['bibtex.md'])
        self.assertEqual(r.requirement, "Requirement Three")

        r = req['test_get_requirements_spec0'][3]
        self.assertEqual(r.issues, ['#4567'])
        self.assertEqual(r.design, ['katex.md'])
        self.assertEqual(r.requirement, "Requirement Four")

        r = req['test_get_requirements_spec0'][4]
        self.assertEqual(r.issues, ['#1234'])
        self.assertEqual(r.design, ['core.md'])
        self.assertEqual(r.requirement, "Requirement Group One")
        self.assertEqual(len(r.details), 2)

        d = r.details[0]
        self.assertEqual(d.name, 'group0-a')
        self.assertEqual(d.detail, '1D')
        self.assertEqual(d.detail_line, 27)

        d = r.details[1]
        self.assertEqual(d.name, 'group0-b')
        self.assertEqual(d.detail, '2D')
        self.assertEqual(d.detail_line, 30)

        r = req['test_get_requirements_spec0'][5]
        self.assertEqual(r.issues, ['#8910'])
        self.assertEqual(r.design, ['core.md'])
        self.assertEqual(r.requirement, "Requirement Group Two")
        self.assertEqual(len(r.details), 2)

        d = r.details[0]
        self.assertEqual(d.name, 'group1-a')
        self.assertEqual(d.detail, '3D')
        self.assertEqual(d.detail_line, 38)

        d = r.details[1]
        self.assertEqual(d.name, 'group1-b')
        self.assertEqual(d.detail, '4D')
        self.assertEqual(d.detail_line, 41)

        r = req['test_get_requirements_spec0'][6]
        self.assertEqual(r.issues, ['#1234'])
        self.assertEqual(r.design, ['bibtex.md'])
        self.assertEqual(r.requirement, "Requirement Group Three")
        self.assertEqual(len(r.details), 2)

        d = r.details[0]
        self.assertEqual(d.name, 'group2-a')
        self.assertEqual(d.detail, '5D')
        self.assertEqual(d.detail_line, 50)

        d = r.details[1]
        self.assertEqual(d.name, 'group2-b')
        self.assertEqual(d.detail, '6D')
        self.assertEqual(d.detail_line, 53)

        r = req['test_get_requirements_spec0'][7]
        self.assertEqual(r.issues, ['#4321'])
        self.assertEqual(r.design, ['katex.md'])
        self.assertEqual(r.requirement, "Requirement Group Four")
        self.assertEqual(len(r.details), 2)

        d = r.details[0]
        self.assertEqual(d.name, 'group3-a')
        self.assertEqual(d.detail, '7D')
        self.assertEqual(d.detail_line, 62)

        d = r.details[1]
        self.assertEqual(d.name, 'group3-b')
        self.assertEqual(d.detail, '8D')
        self.assertEqual(d.detail_line, 65)

        # collections_default
        r = req['test_get_requirements_spec0'][9]
        self.assertIsNone(r.collections)

        # collections_override
        r = req['test_get_requirements_spec0'][10]
        self.assertEqual(r.collections, {'A'})

        # collections_group
        r = req['test_get_requirements_spec0'][11]
        self.assertEqual(r.collections, {'A', 'B'})

        # types
        r = req['test_get_requirements_spec0'][12]
        self.assertEqual(r.types, {'A'})

        # types_group
        r = req['test_get_requirements_spec0'][13]
        self.assertEqual(r.types, {'A', 'B'})

        # names
        r = req['test_get_requirements_spec0'][14]
        self.assertEqual(r.names, {'names'})

        # names_group
        r = req['test_get_requirements_spec0'][15]
        self.assertEqual(r.names, {'names_group/a', 'names_group/b'})

        # prereq_first
        r = req['test_get_requirements_spec0'][16]
        self.assertEqual(r.prerequisites, set())

        # prereq_first
        r = req['test_get_requirements_spec0'][17]
        self.assertEqual(r.prerequisites, {'prereq_first'})

        # prereq_group
        r = req['test_get_requirements_spec0'][18]
        self.assertEqual(r.prerequisites, {'prereq_first', 'prereq_group/a'})