llvm/llvm/test/Other/ChangePrinters/lit.local.cfg

import os
import subprocess


def have_needed_diff_support():
    if not os.path.exists("/usr/bin/diff"):
        return False

    ld_cmd = subprocess.Popen(
        ["/usr/bin/diff", "--help"],
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
        env={"LANG": "C"},
    )
    ld_out = ld_cmd.stdout.read().decode()
    ld_cmd.wait()

    return "-line-format" in ld_out


if not have_needed_diff_support():
    config.unsupported = True