diff --git a/check.sh b/check.sh index bb72f15..67f703e 100755 --- a/check.sh +++ b/check.sh @@ -85,10 +85,10 @@ if [[ ! -d $CHECK_PATH ]]; then CHECK_PATH="." fi -if [[ ! -f $FORMAT_FILEPATH ]]; then +if [[ -n $FORMAT_FILEPATH ]] && [[ ! -f $FORMAT_FILEPATH ]]; then echo "Not a file in the workspace, fallback to search for .clang_format." >&2 FORMAT_FILEPATH="" -else +elif [[ -n $FORMAT_FILEPATH ]]; then # if being used, add the colon for seperating the syntax file: FORMAT_FILEPATH=":$FORMAT_FILEPATH" fi diff --git a/test/.clang-format b/test/format_files/clang_format_example similarity index 100% rename from test/.clang-format rename to test/format_files/clang_format_example diff --git a/test/test.sh b/test/test.sh index ac8b7f8..057f66c 100755 --- a/test/test.sh +++ b/test/test.sh @@ -3,13 +3,14 @@ FALLBACK_STYLE="llvm" EXCLUDE_REGEX="capital" CLANG_FORMAT_VERSION="$1" +CLANG_FORMAT_FILEPATH="$GITHUB_WORKSPACE/test/format_files/clang_format_example" ############################################################################### # Default C/C++/Protobuf/CUDA regex # ############################################################################### # should succeed -"$GITHUB_WORKSPACE"/check.sh "$CLANG_FORMAT_VERSION" "$GITHUB_WORKSPACE/test/known_pass" "$FALLBACK_STYLE" "$EXCLUDE_REGEX" +"$GITHUB_WORKSPACE"/check.sh "$CLANG_FORMAT_VERSION" "$GITHUB_WORKSPACE/test/known_pass" "$FALLBACK_STYLE" "$EXCLUDE_REGEX" "" "$CLANG_FORMAT_FILEPATH" docker_status="$?" if [[ $docker_status != "0" ]]; then echo "files that should succeed have failed!" @@ -17,7 +18,7 @@ if [[ $docker_status != "0" ]]; then fi # should fail -"$GITHUB_WORKSPACE"/check.sh "$CLANG_FORMAT_VERSION" "$GITHUB_WORKSPACE/test/known_fail" "$FALLBACK_STYLE" "$EXCLUDE_REGEX" +"$GITHUB_WORKSPACE"/check.sh "$CLANG_FORMAT_VERSION" "$GITHUB_WORKSPACE/test/known_fail" "$FALLBACK_STYLE" "$EXCLUDE_REGEX" "" "$CLANG_FORMAT_FILEPATH" docker_status="$?" if [[ $docker_status == "0" ]]; then echo "files that should fail have succeeded!" @@ -26,7 +27,7 @@ fi # load test on known_pass/addition.c copies -"$GITHUB_WORKSPACE"/check.sh "$CLANG_FORMAT_VERSION" "$GITHUB_WORKSPACE/test/load_test" "$FALLBACK_STYLE" "$EXCLUDE_REGEX" +"$GITHUB_WORKSPACE"/check.sh "$CLANG_FORMAT_VERSION" "$GITHUB_WORKSPACE/test/load_test" "$FALLBACK_STYLE" "$EXCLUDE_REGEX" "" "$CLANG_FORMAT_FILEPATH" docker_status="$?" if [[ $docker_status != "0" ]]; then echo "files that should succeed have failed in the loadtest!" @@ -40,7 +41,7 @@ fi INCLUDE_REGEX='^.*\.(c|C)' # should succeed -"$GITHUB_WORKSPACE"/check.sh "$CLANG_FORMAT_VERSION" "$GITHUB_WORKSPACE/test/known_pass" "$FALLBACK_STYLE" "$EXCLUDE_REGEX" "$INCLUDE_REGEX" +"$GITHUB_WORKSPACE"/check.sh "$CLANG_FORMAT_VERSION" "$GITHUB_WORKSPACE/test/known_pass" "$FALLBACK_STYLE" "$EXCLUDE_REGEX" "$INCLUDE_REGEX" "$CLANG_FORMAT_FILEPATH" docker_status="$?" if [[ $docker_status != "0" ]]; then echo "files that should succeed have failed!" @@ -48,7 +49,7 @@ if [[ $docker_status != "0" ]]; then fi # should fail -"$GITHUB_WORKSPACE"/check.sh "$CLANG_FORMAT_VERSION" "$GITHUB_WORKSPACE/test/known_fail" "$FALLBACK_STYLE" "$EXCLUDE_REGEX" "$INCLUDE_REGEX" +"$GITHUB_WORKSPACE"/check.sh "$CLANG_FORMAT_VERSION" "$GITHUB_WORKSPACE/test/known_fail" "$FALLBACK_STYLE" "$EXCLUDE_REGEX" "$INCLUDE_REGEX" "$CLANG_FORMAT_FILEPATH" docker_status="$?" if [[ $docker_status == "0" ]]; then echo "files that should fail have succeeded!"