summaryrefslogtreecommitdiffstats
path: root/tools/lint/test/test_file_perm.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lint/test/test_file_perm.py')
-rw-r--r--tools/lint/test/test_file_perm.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/lint/test/test_file_perm.py b/tools/lint/test/test_file_perm.py
new file mode 100644
index 0000000000..08d6a20eef
--- /dev/null
+++ b/tools/lint/test/test_file_perm.py
@@ -0,0 +1,35 @@
+import mozunit
+import pytest
+
+LINTER = "file-perm"
+
+
+@pytest.mark.lint_config(name="file-perm")
+def test_lint_file_perm(lint, paths):
+ results = lint(paths("no-shebang"), collapse_results=True)
+
+ assert results.keys() == {
+ "no-shebang/bad.c",
+ "no-shebang/bad-shebang.c",
+ "no-shebang/bad.png",
+ }
+
+ for path, issues in results.items():
+ for issue in issues:
+ assert "permissions on a source" in issue.message
+ assert issue.level == "error"
+
+
+@pytest.mark.lint_config(name="maybe-shebang-file-perm")
+def test_lint_shebang_file_perm(config, lint, paths):
+ results = lint(paths("maybe-shebang"))
+
+ assert len(results) == 1
+
+ assert "permissions on a source" in results[0].message
+ assert results[0].level == "error"
+ assert results[0].relpath == "maybe-shebang/bad.js"
+
+
+if __name__ == "__main__":
+ mozunit.main()