mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 23:35:34 +00:00
Bug 1591195 - [lint.shellcheck] Ensure shellcheck subprocess output is returned as text, r=sylvestre
This also adds a test which would have caught the issue. Differential Revision: https://phabricator.services.mozilla.com/D50621 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
b6ddb7ea53
commit
6368d98850
@ -27,6 +27,7 @@ results = []
|
||||
class ShellcheckProcess(ProcessHandlerMixin):
|
||||
def __init__(self, config, *args, **kwargs):
|
||||
self.config = config
|
||||
kwargs['universal_newlines'] = True
|
||||
kwargs['processOutputLine'] = [self.process_line]
|
||||
ProcessHandlerMixin.__init__(self, *args, **kwargs)
|
||||
|
||||
|
3
tools/lint/test/files/shellcheck/bad.sh
Normal file
3
tools/lint/test/files/shellcheck/bad.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
hello="Hello world"
|
||||
echo $1
|
2
tools/lint/test/files/shellcheck/good.sh
Normal file
2
tools/lint/test/files/shellcheck/good.sh
Normal file
@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
echo "Hello world"
|
@ -12,3 +12,4 @@ skip-if = os == "win"
|
||||
[test_file_whitespace.py]
|
||||
[test_file_license.py]
|
||||
[test_lintpref.py]
|
||||
[test_shellcheck.py]
|
||||
|
24
tools/lint/test/test_shellcheck.py
Normal file
24
tools/lint/test/test_shellcheck.py
Normal file
@ -0,0 +1,24 @@
|
||||
import pytest
|
||||
import mozunit
|
||||
from mozfile import which
|
||||
|
||||
LINTER = 'shellcheck'
|
||||
pytestmark = pytest.mark.skipif(not which('shellcheck'), reason="shellcheck is not installed")
|
||||
|
||||
|
||||
def test_basic(lint, paths):
|
||||
results = lint(paths())
|
||||
print(results)
|
||||
assert len(results) == 2
|
||||
|
||||
assert "hello appears unused" in results[0].message
|
||||
assert results[0].level == "error"
|
||||
assert results[0].relpath == "bad.sh"
|
||||
|
||||
assert "Double quote to prevent" in results[1].message
|
||||
assert results[1].level == "error"
|
||||
assert results[1].relpath == "bad.sh"
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
mozunit.main()
|
Loading…
Reference in New Issue
Block a user