def test_ignore_werror_unknown_lang():
    ignore_werror = IgnoreWerror({})
    cxx = CXX(["-x", "-unknownlanguage", "-Werror"])

    ignore_werror.before_run(cxx)

    assert cxx.args == shlex.split("-x -unknownlanguage -Werror")
def test_ignore_werror_cxx():
    ignore_werror = IgnoreWerror({})
    cxx = CXX(["-Wall", "-Werror", "-O3", "-Werror"])

    ignore_werror.before_run(cxx)

    assert cxx.args == shlex.split("-Wall -O3")
def test_ignore_werror_unknown_lang():
    ignore_flags = IgnoreFlags({"FLAGS": "-Wextra -ffunction-sections"})
    cxx = CXX(["-x", "-unknownlanguage", "-Werror"])

    ignore_flags.before_run(cxx)

    assert cxx.args == shlex.split("-x -unknownlanguage -Werror")
def test_inject_flags_unknown_lang():
    inject_flags = InjectFlags({
        "CFLAGS": "-these -are -ignored",
        "CXXFLAGS": "-so -are -these",
        "CPPFLAGS": "-and -this"
    })
    cxx = CXX(["-x", "-unknownlanguage"])

    inject_flags.before_run(cxx)

    assert cxx.args == shlex.split("-x -unknownlanguage")
def test_inject_flags_cxx():
    inject_flags = InjectFlags({
        "CFLAGS": "-these -are -ignored",
        "CXXFLAGS": "-more -flags",
        "CPPFLAGS": "-bar"
    })
    cxx = CXX(["-fake", "-flags"])

    inject_flags.before_run(cxx)

    assert cxx.args == shlex.split("-fake -flags -more -flags -bar")
def test_inject_linker_flags():
    inject_flags = InjectFlags({
        "CFLAGS": "-cc-flags",
        "CFLAGS_LINKER": "-c-linker-flags",
        "CXXFLAGS": "-cxx-flags",
        "CXXFLAGS_LINKER": "-cxx-linker-flags",
    })

    cc_nolink = CC(["-c"])
    cc_link = CC(["-fake", "-flags"])
    cxx_nolink = CXX(["-c"])
    cxx_link = CXX(["-fake", "-flags"])

    inject_flags.before_run(cc_nolink)
    inject_flags.before_run(cc_link)
    inject_flags.before_run(cxx_nolink)
    inject_flags.before_run(cxx_link)

    assert cc_nolink.args == shlex.split("-c -cc-flags")
    assert cc_link.args == shlex.split(
        "-fake -flags -cc-flags -c-linker-flags")
    assert cxx_nolink.args == shlex.split("-c -cxx-flags")
    assert cxx_link.args == shlex.split(
        "-fake -flags -cxx-flags -cxx-linker-flags")