Beispiel #1
0
    def test_invalid_configuration(self):
        utils.remove_file('vsg/tests/vsg/config_error.actual.xml')
        lExpected = []
        lExpected.append(
            'ERROR: Invalid configuration file: vsg/tests/vsg/config_error.json'
        )
        lExpected.append('while parsing a flow node')
        lExpected.append('expected the node content, but found \',\'')
        lExpected.append(
            '  in "vsg/tests/vsg/config_error.json", line 2, column 16')
        lExpected.append('')

        lActual = subprocess.check_output([
            'bin/vsg', '--configuration', 'vsg/tests/vsg/config_error.json',
            '--output_format', 'syntastic', '-f', 'vsg/tests/vsg/entity1.vhd',
            '--junit', 'vsg/tests/vsg/config_error.actual.xml'
        ])
        lActual = str(lActual.decode('utf-8')).split('\n')
        self.assertEqual(lActual, lExpected)
        # Read in the expected JUnit XML file for comparison
        lExpected = []
        utils.read_file(
            os.path.join(os.path.dirname(__file__),
                         'config_error.expected.xml'), lExpected)
        # Read in the actual JUnit XML file for comparison
        lActual = []
        utils.read_file(
            os.path.join(os.path.dirname(__file__), 'config_error.actual.xml'),
            lActual)
        # Compare the two files, but skip the line with the timestamp (as it will never match)
        for iLineNumber, sLine in enumerate(lExpected):
            if iLineNumber != 1:
                self.assertEqual(sLine, lActual[iLineNumber])
        # Clean up
        utils.remove_file('vsg/tests/vsg/config_error.actual.xml')
Beispiel #2
0
    def test_invalid_configuration(self, mock_stdout):
#    def test_invalid_configuration(self):
        utils.remove_file('vsg/tests/vsg/config_error.actual.xml')
        lExpected = []
        lExpected.append(mock.call('ERROR: Invalid configuration file: vsg/tests/vsg/config_error.json'))
        lExpected.append(mock.call('\n'))
        lExpected.append(mock.call('while parsing a flow node\nexpected the node content, but found \',\'\n  in "vsg/tests/vsg/config_error.json", line 2, column 16'))
        lExpected.append(mock.call('\n'))

        sys.argv = ['vsg']
        sys.argv.extend(['--output_format', 'syntastic'])
        sys.argv.extend(['--configuration', 'vsg/tests/vsg/config_error.json'])
        sys.argv.extend(['-f', 'vsg/tests/vsg/entity1.vhd'])
        sys.argv.extend(['--junit', 'vsg/tests/vsg/config_error.actual.xml'])

        try:
            __main__.main()
        except SystemExit:
            pass

        mock_stdout.write.assert_has_calls(lExpected)

        # Read in the expected JUnit XML file for comparison
        lExpected = []
        utils.read_file(os.path.join(os.path.dirname(__file__),'config_error.expected.xml'), lExpected)
        # Read in the actual JUnit XML file for comparison
        lActual = []
        utils.read_file(os.path.join(os.path.dirname(__file__),'config_error.actual.xml'), lActual)
        # Compare the two files, but skip the line with the timestamp (as it will never match)
        for iLineNumber, sLine in enumerate(lExpected):
            if iLineNumber != 1:
                self.assertEqual(sLine, lActual[iLineNumber])
        # Clean up
        utils.remove_file('vsg/tests/vsg/config_error.actual.xml')