Commit ba6d6390 authored by Jan Kiene's avatar Jan Kiene
Browse files

Merge branch 'add_test_for_linux_compiler_warnings' into 'main'

Add test for linux compiler warnings

See merge request !47
parents a66820ad db720748
Loading
Loading
Loading
Loading
+46 −8
Original line number Diff line number Diff line
variables:
  TESTV_DIR: "/usr/local/testv"

  BUILD_OUTPUT: "build_output.txt"

# prevent running two pipelines on pushes to merge request branches
workflow:
@@ -38,18 +38,53 @@ stages:
    - if [ ! -d "$TESTV_DIR" ]; then mkdir -p $TESTV_DIR; fi
    - cp -r scripts/testv/* $TESTV_DIR/


# build all components of the project, i.e. codec itself, the unittests, the prerenderer and the standalone version of the TD object renderer
build-all-linux-make:
# template for build jobs to include the check for warnings
.build-job-with-check-for-warnings:
  extends: .test-job-linux
  stage: build
  allow_failure:
    exit_codes:
      - 123


build-codec-linux-make:
  extends: .build-job-with-check-for-warnings
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    - make -j 2>&1 | tee $BUILD_OUTPUT
    # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...<
    - ci/check_for_warnings.py $BUILD_OUTPUT || exit $?

build-unittests-linux:
  extends: .build-job-with-check-for-warnings
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    - make unittests -j 2>&1 | tee $BUILD_OUTPUT
    # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...<
    - ci/check_for_warnings.py $BUILD_OUTPUT || exit $?

build-prerenderer-linux:
  extends: .build-job-with-check-for-warnings
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    - make -C scripts/prerenderer -j 2>&1 | tee $BUILD_OUTPUT
    # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...<
    - ci/check_for_warnings.py $BUILD_OUTPUT || exit $?

build-td-object-renderer-standalone-linux:
  extends: .build-job-with-check-for-warnings
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  stage: build
  script:
    - bash ci/build_all_linux.sh
    - make -C scripts/td_object_renderer/object_renderer_standalone -j 2>&1 | tee $BUILD_OUTPUT
    # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...<
    - ci/check_for_warnings.py $BUILD_OUTPUT || exit $?

build-codec-linux-cmake:
  extends: .test-job-linux
  extends: .build-job-with-check-for-warnings
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  stage: build
@@ -57,7 +92,10 @@ build-codec-linux-cmake:
    - mkdir build
    - cd build
    - cmake ..
    - make -j
    - cd ..
    - make -C build -j 2>&1 | tee $BUILD_OUTPUT
    # need to use the "|| exit $?" suffix to get the allowed_failure return code, otherwise the job fails with code 1...<
    - ci/check_for_warnings.py $BUILD_OUTPUT || exit $?

build-codec-instrumented-linux:
  extends: .test-job-linux
+33 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
import argparse
import sys


SEARCH_FOR = "warning:"
RETURN_FOUND = 123


def main(log_file):
    with open(log_file) as f:
        lines_with_warnings = [l for l in f.readlines() if SEARCH_FOR in l]

    n_warnings = len(lines_with_warnings)
    if n_warnings > 0:
        print(f"========== Found {n_warnings} warnings: =========")
        for l in lines_with_warnings:
            print(l)
        return RETURN_FOUND
    else:
        return 0


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "compilation-output",
        type=str,
        help="text output of compilation process to analyze",
    )
    args = vars(parser.parse_args())
    ret_code = main(args[ "compilation-output" ])
    sys.exit(ret_code)