Repository: bitcoin/bitcoin
File: .github/ci-test-each-commit-exec.py (Python)

Code before:
    try:
        return subprocess.run(cmd, check=True, **kwargs)
    except Exception as e:
        sys.exit(e)


def main():
    print("Running test-one-commit on ...")
    run(["git", "log", "-1"])

    num_procs = int(run(["nproc"], stdout=subprocess.PIPE).stdout)

    # Use clang++, because it is a bit faster and uses less memory than g++
    run([
        "cmake",
        "-B",
        "build",
        "-Werror=dev",
        "-DCMAKE_C_COMPILER=clang",
        "-DCMAKE_CXX_COMPILER=clang++",
        "-DWERROR=ON",
        "-DWITH_ZMQ=ON",
        "-DBUILD_GUI=ON",
        "-DBUILD_BENCH=ON",
        "-DBUILD_FUZZ_BINARY=ON",
        "-DWITH_USDT=ON",
        "-DCMAKE_CXX_FLAGS=-Wno-error=unused-member-function",
    ])
    run(["cmake", "--build", "build", "-j", str(num_procs)])
    run([
        "ctest",
        "--output-on-failure",
        "--stop-on-failure",
        "--test-dir",
        "build",
        "-j",
        str(num_procs),
    ])
    run([
        sys.executable,
        "./build/test/functional/test_runner.py",
        "-j",
        str(num_procs * 2),
        "--combinedlogslen=99999999",
    ])


if __name__ == "__main__":
    main()


Review comment (bug):
Is `-03` chosen here to try and counteract the slow-down from `Debug` as opposed to using `-02`?

IIRC I did some tests of `-02` vs `-03` and didn't find much/any speedup, so just curious if that was the reason. If it's been chosen to expose new classes of bugs not found by `-03`, then seems fine to me.

How does `-03` actually play with `-g2`? Do the agressive optimisations play OK with debugging? (I've never tried this combination I don't think.)

Code after:
    try:
        return subprocess.run(cmd, check=True, **kwargs)
    except Exception as e:
        sys.exit(e)


def main():
    print("Running tests on commit ...")
    run(["git", "log", "-1"])

    num_procs = int(run(["nproc"], stdout=subprocess.PIPE).stdout)

    run([
        "cmake",
        "-B",
        "build",
        "-Werror=dev",
        # Use clang++, because it is a bit faster and uses less memory than g++
        "-DCMAKE_C_COMPILER=clang",
        "-DCMAKE_CXX_COMPILER=clang++",
        # Use mold, because it is faster than the default linker
        "-DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=mold",
        # Use Debug build type for more debug checks, but enable optimizations
        "-DAPPEND_CXXFLAGS='-O3 -g2'",
        "-DAPPEND_CFLAGS='-O3 -g2'",
        "-DCMAKE_BUILD_TYPE=Debug",
        "-DWERROR=ON",
        "-DWITH_ZMQ=ON",
        "-DBUILD_GUI=ON",
        "-DBUILD_BENCH=ON",
        "-DBUILD_FUZZ_BINARY=ON",
        "-DWITH_USDT=ON",
        "-DCMAKE_CXX_FLAGS=-Wno-error=unused-member-function",
    ])
    run(["cmake", "--build", "build", "-j", str(num_procs)])
    run([
        "ctest",
        "--output-on-failure",
        "--stop-on-failure",
        "--test-dir",
        "build",
        "-j",
        str(num_procs),
    ])
    run([
        sys.executable,
        "./build/test/functional/test_runner.py",
        "-j",
        str(num_procs * 2),
        "--combinedlogslen=99999999",
    ])