#!/usr/bin/env python3

"""
Warn for use of `--interactive` inside Makefiles (#11468).

Encourage the use of `$(TEST_HC_OPTS_INTERACTIVE)` instead of
`$(TEST_HC_OPTS) --interactive -ignore-dot-ghci -v0`. It's too easy to
forget one of those flags when adding a new test.
"""

from linter import run_linters, RegexpLinter

linters = [
    RegexpLinter(r'--interactive',
                 message = "Warning: Use `$(TEST_HC_OPTS_INTERACTIVE)` instead of `--interactive -ignore-dot-ghci -v0`."
                ).add_path_filter(lambda path: path.name == 'Makefile')
]

if __name__ == '__main__':
    run_linters(linters,
                subdir='testsuite')

@@ -17,16 +17,103 @@
 ython3%0A%0A
+%22%22%22%0ALinters for testsuite makefiles%0A%22%22%22%0A%0Afrom linter import run_linters, RegexpLinter%0A%0A
 %22%22%22%0AWarn
@@ -359,66 +359,30 @@
 %22%22%22%0A
-%0Afrom linter import run_linters, RegexpLinter%0A%0A
+interactive_
 linter
-s
  = 
-%5B
+%5C
 %0A   
@@ -605,16 +605,299 @@
 kefile')
+%0A%0Atest_hc_quotes_linter = %5C%0A    RegexpLinter('%5Ct%5C%5C$%5C%5C(TEST_HC%5C%5C)',%0A                 message = %22Warning: $(TEST_HC) should be quoted in Makefiles.%22,%0A                ).add_path_filter(lambda path: path.name == 'Makefile')%0A%0Alinters = %5B%0A    interactive_linter,%0A    test_hc_quotes_linter,
 %0A%5D%0A%0Aif _

Add linter to catch unquoted use of $(TEST_HC)