mirror of
https://github.com/servo/servo.git
synced 2025-06-08 00:23:30 +00:00
Add linting for shell scripts
This changes tidy to check shell scripts for the proper shebang and options. It does not check that variables are formatted correctly. It also adds a check for the MPL 2.0 license in shell scripts.
This commit is contained in:
parent
1e0321f7dd
commit
7952bd00b6
10 changed files with 104 additions and 13 deletions
7
python/tidy/servo_tidy_tests/shell_tidy.sh
Normal file
7
python/tidy/servo_tidy_tests/shell_tidy.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Tests tidy for shell scripts.
|
||||
|
||||
set -o nounset
|
||||
|
||||
echo "hello world"
|
|
@ -48,6 +48,12 @@ class CheckTidiness(unittest.TestCase):
|
|||
self.assertEqual('incorrect license', errors.next()[2])
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
def test_shell(self):
|
||||
errors = tidy.collect_errors_for_files(iterFile('shell_tidy.sh'), [], [tidy.check_shell], print_text=False)
|
||||
self.assertEqual('script does not have shebang "#!/usr/bin/env bash"', errors.next()[2])
|
||||
self.assertEqual('script is missing options "set -o errexit", "set -o pipefail"', errors.next()[2])
|
||||
self.assertNoMoreErrors(errors)
|
||||
|
||||
def test_rust(self):
|
||||
errors = tidy.collect_errors_for_files(iterFile('rust_tidy.rs'), [], [tidy.check_rust], print_text=False)
|
||||
self.assertEqual('use statement spans multiple lines', errors.next()[2])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue