def test_process_output_should_not_be_colored(self): original = ' x error - x ' expected = u' x error - x ' old, new = '(?P<name>Error[^ -]*)', u'\033[00;31m\g<name>\033[0m' output = _process_output(original, old, new) self.assertEqual(expected, output) original = ' x (E12A) x x E123 x' expected = u' x (E12A) x x E123 x' old, new = '\((?P<name>E\d\d\d)\)', u'(\033[00;31m\g<name>\033[0m)' output = _process_output(original, old, new) self.assertEqual(expected, output)
def code_analysis_jshint(options): log('title', 'JSHint') jenkins = _normalize_boolean(options['jenkins']) # cmd is a sequence of program arguments # first argument is child program paths = options['directory'].split('\n') cmd = [ options['jshint-bin'], '--verbose', '--exclude={0}'.format(options['jshint-exclude'] or ' ')] + paths try: if jenkins: cmd.append('--reporter=jslint') output_file_name = os.path.join(options['location'], 'jshint.xml') output_file = open(output_file_name, 'w+') else: output_file = TemporaryFile('w+') # Wrapper to subprocess.Popen try: # Return code is not used for jshint. output = _read_subprocess_output(cmd, output_file)[0] except OSError: log('skip') return False finally: output_file.close() # HACK: workaround for JSHint limitations if jshint_errors(output, jenkins): if jenkins: log('failure', 'Output file written to %s.' % output_file_name) else: # Name the pattern to use it in the substitution. old, new = '\((?P<name>E\d\d\d)\)', u'(\033[00;31m\g<name>\033[0m)' log('failure', _process_output(output, old, new)) return False else: log('ok') if output != '' and not jenkins: print(output) # XXX: there should be warnings on the output return True
def test_process_output_jshint_should_be_colored(self): original = ' x (E000) x ' expected = u' x (\033[00;31mE000\033[0m) x ' old, new = '\((?P<name>E\d\d\d)\)', u'(\033[00;31m\g<name>\033[0m)' output = _process_output(original, old, new) self.assertEqual(expected, output)
def test_process_output_csslint_should_be_colored(self): original = ' x Error - x ' expected = u' x \033[00;31mError\033[0m - x ' old, new = '(?P<name>Error[^ -]*)', u'\033[00;31m\g<name>\033[0m' output = _process_output(original, old, new) self.assertEqual(expected, output)