diff --git a/tools/lint/codespell.yml b/tools/lint/codespell.yml index 2366c41c7a19..80bfae550743 100644 --- a/tools/lint/codespell.yml +++ b/tools/lint/codespell.yml @@ -52,6 +52,8 @@ codespell: - tools/docs/ - tools/lint/ - tools/tryselect/ + excludes: + - tools/lint/test/test_codespell.py # List of extensions coming from: # tools/lint/{flake8,eslint}.yml # tools/mach_commands.py (clang-format) diff --git a/tools/lint/test/files/codespell/ignore.rst b/tools/lint/test/files/codespell/ignore.rst new file mode 100644 index 000000000000..1371d07054e5 --- /dev/null +++ b/tools/lint/test/files/codespell/ignore.rst @@ -0,0 +1,5 @@ +This is a file with some typos and informations. +But also testing false positive like optin (because this isn't always option) +or stuff related to our coding style like: +aparent (aParent). +but detects mistakes like mozila diff --git a/tools/lint/test/python.ini b/tools/lint/test/python.ini index 2efb6276af4b..f184752beb9c 100644 --- a/tools/lint/test/python.ini +++ b/tools/lint/test/python.ini @@ -13,4 +13,6 @@ skip-if = os == "win" [test_file_license.py] [test_lintpref.py] [test_shellcheck.py] -[test_rst.py] \ No newline at end of file +[test_rst.py] +[test_codespell.py] +skip-if = os == "win" || os == "mac" # codespell installed on Linux diff --git a/tools/lint/test/test_codespell.py b/tools/lint/test/test_codespell.py new file mode 100644 index 000000000000..86226966bd3d --- /dev/null +++ b/tools/lint/test/test_codespell.py @@ -0,0 +1,24 @@ +from __future__ import absolute_import, print_function + +import mozunit + +LINTER = 'codespell' + + +def test_lint_codespell(lint, paths): + results = lint(paths()) + assert len(results) == 2 + + assert results[0].message == 'informations ==> information' + assert results[0].level == "error" + assert results[0].lineno == 1 + assert results[0].relpath == "ignore.rst" + + assert results[1].message == "mozila ==> mozilla" + assert results[1].level == "error" + assert results[1].lineno == 5 + assert results[1].relpath == "ignore.rst" + + +if __name__ == '__main__': + mozunit.main()