Skip to content

Commit

Permalink
add tests, fix extra verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
jr1221 committed Aug 6, 2024
1 parent 90955bb commit cbb9a04
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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:<file_name>
FORMAT_FILEPATH=":$FORMAT_FILEPATH"
fi
Expand Down
File renamed without changes.
11 changes: 6 additions & 5 deletions test/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@
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!"
exit 1
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!"
Expand All @@ -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!"
Expand All @@ -40,15 +41,15 @@ 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!"
exit 1
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!"
Expand Down

0 comments on commit cbb9a04

Please sign in to comment.