Skip to content

Commit

Permalink
update CLICOLOR_FORCE unit test for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
cconverse711 committed Apr 12, 2024
1 parent c898fc3 commit c63cb27
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions test/cli/other_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,25 @@ def test_clicolor_force(tmpdir):
test_file = os.path.join(tmpdir, 'test.c')
with open(test_file, 'wt') as f:
f.write('#error test\nx=1;\n')
_, _, stderr = cppcheck([test_file], env={"CLICOLOR_FORCE":"1"})
exitcode, _, stderr = cppcheck([test_file], env={"CLICOLOR_FORCE":"1"})

ANSI_BOLD = "\x1b[1m"
ANSI_FG_RED = "\x1b[31m"
ANSI_FG_DEFAULT = "\x1b[39m"
ANSI_FG_RESET = "\x1b[0m"
assert ANSI_BOLD in stderr
assert ANSI_FG_RED in stderr
assert ANSI_FG_DEFAULT in stderr
assert ANSI_FG_RESET in stderr

assert exitcode == 0
if sys.platform == "win32":
assert stderr
assert ANSI_BOLD not in stderr
assert ANSI_FG_RED not in stderr
assert ANSI_FG_DEFAULT not in stderr
assert ANSI_FG_RESET not in stderr
else:
assert ANSI_BOLD in stderr
assert ANSI_FG_RED in stderr
assert ANSI_FG_DEFAULT in stderr
assert ANSI_FG_RESET in stderr


def test_invalid_library(tmpdir):
Expand Down

0 comments on commit c63cb27

Please sign in to comment.