Skip to content

Commit 40ed57c

Browse files
[CI] Prefer Bash Tests over Empty String Comparisons (#168575)
These are more idiomatic in bash.
1 parent 8bdd82c commit 40ed57c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

.ci/monolithic-linux.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,13 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
6464

6565
start-group "ninja"
6666

67-
if [[ "${targets}" != "" ]]; then
67+
if [[ -n "${targets}" ]]; then
6868
# Targets are not escaped as they are passed as separate arguments.
6969
ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log
7070
cp ${BUILD_DIR}/.ninja_log ninja.ninja_log
7171
fi
7272

73-
if [[ "${runtime_targets}" != "" ]]; then
73+
if [[ -n "${runtime_targets}" ]]; then
7474
start-group "ninja Runtimes"
7575

7676
ninja -C "${BUILD_DIR}" ${runtime_targets} |& tee ninja_runtimes.log
@@ -79,7 +79,7 @@ fi
7979

8080
# Compiling runtimes with just-built Clang and running their tests
8181
# as an additional testing for Clang.
82-
if [[ "${runtime_targets_needs_reconfig}" != "" ]]; then
82+
if [[ -n "${runtime_targets_needs_reconfig}" ]]; then
8383
start-group "CMake Runtimes C++26"
8484

8585
cmake \

.ci/monolithic-windows.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
5151

5252
start-group "ninja"
5353

54-
if [[ "${targets}" != "" ]]; then
54+
if [[ -n "${targets}" ]]; then
5555
# Targets are not escaped as they are passed as separate arguments.
5656
ninja -C "${BUILD_DIR}" -k 0 ${targets} |& tee ninja.log
5757
cp ${BUILD_DIR}/.ninja_log ninja.ninja_log
5858
fi
5959

60-
if [[ "${runtimes_targets}" != "" ]]; then
60+
if [[ -n "${runtimes_targets}" ]]; then
6161
start-group "ninja runtimes"
6262

6363
ninja -C "${BUILD_DIR}" -k 0 ${runtimes_targets} |& tee ninja_runtimes.log

.ci/utils.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function at-exit {
3333
# If building fails there will be no results files.
3434
shopt -s nullglob
3535

36-
if [[ "$GITHUB_ACTIONS" != "" ]]; then
36+
if [[ -n "$GITHUB_ACTIONS" ]]; then
3737
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py \
3838
$retcode "${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log \
3939
>> $GITHUB_STEP_SUMMARY
@@ -44,7 +44,7 @@ function at-exit {
4444
fi
4545

4646
if [[ "$retcode" != "0" ]]; then
47-
if [[ "$GITHUB_ACTIONS" != "" ]]; then
47+
if [[ -n "$GITHUB_ACTIONS" ]]; then
4848
python "${MONOREPO_ROOT}"/.ci/premerge_advisor_upload.py \
4949
$(git rev-parse HEAD~1) $GITHUB_RUN_NUMBER \
5050
"${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log
@@ -59,10 +59,10 @@ trap at-exit EXIT
5959

6060
function start-group {
6161
groupname=$1
62-
if [[ "$GITHUB_ACTIONS" != "" ]]; then
62+
if [[ -n "$GITHUB_ACTIONS" ]]; then
6363
echo "::endgroup"
6464
echo "::group::$groupname"
65-
elif [[ "$POSTCOMMIT_CI" != "" ]]; then
65+
elif [[ -n "$POSTCOMMIT_CI" ]]; then
6666
echo "@@@$STEP@@@"
6767
else
6868
echo "Starting $groupname"
@@ -73,6 +73,6 @@ export PIP_BREAK_SYSTEM_PACKAGES=1
7373
pip install -q -r "${MONOREPO_ROOT}"/.ci/all_requirements.txt
7474

7575
# The ARM64 builders run on AWS and don't have access to the GCS cache.
76-
if [[ "$GITHUB_ACTIONS" != "" ]] && [[ "$RUNNER_ARCH" != "ARM64" ]]; then
76+
if [[ -n "$GITHUB_ACTIONS" ]] && [[ "$RUNNER_ARCH" != "ARM64" ]]; then
7777
python .ci/cache_lit_timing_files.py download
7878
fi

0 commit comments

Comments
 (0)