code: def test_issue_1214(self):
      print_red = """rule echo
    command = printf '\x1b[31mred\x1b[0m'
    description = echo $out
  
  build a: echo
  """
      # Only strip color when ninja's output is piped.
      self.assertEqual(
          run(print_red),
          """[1/1] echo a\x1b[K
  \x1b[31mred\x1b[0m
  """,
      )
      self.assertEqual(
          run(print_red, pipe=True),
          """[1/1] echo a
  red
  """,
      )
      # Even in verbose mode, colors should still only be stripped when piped.
      self.assertEqual(
          run(print_red, flags="-v"),
          """[1/1] printf '\x1b[31mred\x1b[0m'
  \x1b[31mred\x1b[0m
  """,
      )
      self.assertEqual(
          run(print_red, flags="-v", pipe=True),
          """[1/1] printf '\x1b[31mred\x1b[0m'
  red
  """,
      )
  
      # CLICOLOR_FORCE=1 can be used to disable escape code stripping.
      env = default_env.copy()
      env["CLICOLOR_FORCE"] = "1"
      self.assertEqual(
          run(print_red, pipe=True, env=env),
          """[1/1] echo a
  \x1b[31mred\x1b[0m
  """,
      )
  
file_path: ninja/misc/output_test.py
imports: import os
  import platform
  import subprocess
  import sys
  import tempfile
  import unittest
label_desc: Use image node_id 2 for calling the Output obj's underlying member method code with example usage: obj.test_issue_1214() without return types