def run_test(self, file_name): checks = TESTS[file_name] test_file = checks['test_file'] # Apply without making any changes to the file (errors, nodes_changed) = lint_i18n_strings.lint_file(test_file, apply_fix=False, verbose=False) self.assertEqual(nodes_changed, checks['nodes_changed'], '# of nodes changed differ in %s' % test_file) self.assertEqual(errors, checks['errors'], 'Errors reported differ in %s' % test_file) self.assertEqual(_slurp(test_file), checks['original'], 'Make sure that the output of the file did not change with ' 'apply_fix=False.') # Test again with apply_fix=True (errors, nodes_changed) = lint_i18n_strings.lint_file(test_file, apply_fix=True, verbose=False) self.assertEqual(nodes_changed, checks['nodes_changed'], '# of nodes changed differ in %s' % test_file) self.assertEqual(errors, checks['errors'][:-1], 'These should be no errors in %s' % test_file) self.assertEqual(_slurp(test_file), _slurp(checks['output_file']), 'Make sure that the output of the file matches the expected ' 'output.')
def run_test(self, file_name): checks = TESTS[file_name] test_file = checks['test_file'] # Apply without making any changes to the file (errors, nodes_changed) = lint_i18n_strings.lint_file(test_file, apply_fix=False, verbose=False) self.assertEqual(nodes_changed, checks['nodes_changed'], '# of nodes changed differ in %s' % test_file) self.assertEqual(errors, checks['errors'], 'Errors reported differ in %s' % test_file) self.assertEqual( _slurp(test_file), checks['original'], 'Make sure that the output of the file did not change with ' 'apply_fix=False.') # Test again with apply_fix=True (errors, nodes_changed) = lint_i18n_strings.lint_file(test_file, apply_fix=True, verbose=False) self.assertEqual(nodes_changed, checks['nodes_changed'], '# of nodes changed differ in %s' % test_file) self.assertEqual(errors, checks['errors'][:-1], 'These should be no errors in %s' % test_file) self.assertEqual( _slurp(test_file), _slurp(checks['output_file']), 'Make sure that the output of the file matches the expected ' 'output.')
def run_test(self, file_name): checks = TESTS[file_name] test_file = checks["test_file"] # Apply without making any changes to the file (errors, nodes_changed) = lint_i18n_strings.lint_file(test_file, apply_fix=False, verbose=False) self.assertEqual(nodes_changed, checks["nodes_changed"], "# of nodes changed differ in %s" % test_file) self.assertEqual(errors, checks["errors"], "Errors reported differ in %s" % test_file) self.assertEqual( _slurp(test_file), checks["original"], "Make sure that the output of the file did not change with " "apply_fix=False.", ) # Test again with apply_fix=True (errors, nodes_changed) = lint_i18n_strings.lint_file(test_file, apply_fix=True, verbose=False) self.assertEqual(nodes_changed, checks["nodes_changed"], "# of nodes changed differ in %s" % test_file) self.assertEqual(errors, checks["errors"][:-1], "These should be no errors in %s" % test_file) self.assertEqual( _slurp(test_file), _slurp(checks["output_file"]), "Make sure that the output of the file matches the expected " "output.", )
def main(files_to_lint): num_errors = 0 lint_i18n_strings.SHOW_PROMPT = False for f in files_to_lint: # We only lint .html files in exercises/ if (not f.endswith('.html') or os.path.basename(os.path.dirname(f)) != 'exercises'): continue (errors, num_fixes) = lint_i18n_strings.lint_file( f, apply_fix=False, verbose=False) if errors: num_errors += len(errors) # The 'E212' is to fit this regexp format to what 'arc # lint' expects. # TODO(csilvers): assign error codes to different types of # errors in lint_i18n_strings.py. # TODO(csilvers): get line number info from lint_i18n_strings. for error_msg in errors: # The error message can refer to lint_i18n_strings as 'me'. error_msg = error_msg.replace('Re-run', 'Run build/lint_i18n_strings.py') print >>sys.stderr, ('%s:1: E212 %s' % (f, error_msg.replace('\n', ' '))) return num_errors
def main(files_to_lint): num_errors = 0 lint_i18n_strings.SHOW_PROMPT = False for f in files_to_lint: # We only lint .html files in exercises/ if (not f.endswith('.html') or os.path.basename(os.path.dirname(f)) != 'exercises'): continue (errors, num_fixes) = lint_i18n_strings.lint_file(f, apply_fix=False, verbose=False) if errors: num_errors += len(errors) # The 'E212' is to fit this regexp format to what 'arc # lint' expects. # TODO(csilvers): assign error codes to different types of # errors in lint_i18n_strings.py. # TODO(csilvers): get line number info from lint_i18n_strings. for error_msg in errors: # The error message can refer to lint_i18n_strings as 'me'. error_msg = error_msg.replace( 'Re-run', 'Run build/lint_i18n_strings.py') print >> sys.stderr, ('%s:1: E212 %s' % (f, error_msg.replace('\n', ' '))) return num_errors