From 91d4b85be4668f1edb7239333a1ed9d1c355b3c0 Mon Sep 17 00:00:00 2001 From: Niall Crowe Date: Wed, 13 Dec 2023 16:10:37 +0000 Subject: [PATCH] set tests to run in bash strict mode (#320) --- apphost-framework-lookup/test.sh | 1 + aspnet-same-runtime-version-2x/test.sh | 2 +- aspnet-same-runtime-version/test.sh | 1 + aspnetpatch-21/test.sh | 1 + bash-completion/test.sh | 1 + bundled-libunwind/test.sh | 2 +- cgroup-limit/test.sh | 2 +- commit-ids-in-binaries/test.sh | 1 - createdump-aspnet/test.sh | 2 +- distribution-packages/test.sh | 2 +- dotnet-info-commit-ids/test.sh | 2 +- dotnet-monitor-works/test.sh | 2 +- dotnet-trace/test.sh | 1 + extract-bundle-dir/test.sh | 1 + fdd-no-nuget/test.sh | 4 +++- helloworld/test.sh | 1 + host-probes-rid-assets-legacy/test.sh | 1 + host-probes-rid-assets/test.sh | 1 + liblttng-ust_sys-sdt.h/test.sh | 1 + libuv-kestrel-sample-app-2x/test.sh | 2 +- lttng/test.sh | 1 + man-pages/test.sh | 1 + nativeaot/test.sh | 2 +- omnisharp/test.sh | 1 - openssl-alpn/test.sh | 1 + pgo-dynamic/test.sh | 2 +- publish-aspnet-selfcontained/test.sh | 1 + publish-dotnet-selfcontained/test.sh | 1 + publish-ready-to-run-linux/test.sh | 1 + publish-ready-to-run/test.sh | 1 + restore-with-rid/test.sh | 1 + system-data-odbc/test.sh | 2 +- system-libunwind/test.sh | 2 +- system-openssl/test.sh | 1 + targeting-packs-bad-files/test.sh | 2 +- telemetry-is-off-by-default/test-telemetry-tcpdump.sh | 1 + telemetry-is-off-by-default/test.sh | 1 + template-test/test.sh | 3 ++- tool-dev-certs/test.sh | 1 + use-current-runtime/test.sh | 2 +- workload/test.sh | 2 +- xunit-smoketest/test.sh | 1 + 42 files changed, 43 insertions(+), 19 deletions(-) diff --git a/apphost-framework-lookup/test.sh b/apphost-framework-lookup/test.sh index 4644713..c6a5816 100755 --- a/apphost-framework-lookup/test.sh +++ b/apphost-framework-lookup/test.sh @@ -8,6 +8,7 @@ fi # because that usually contains lots of "errors". set -euo pipefail +IFS=$'\n\t' set -x runtime_id="$(../runtime-id --portable)" diff --git a/aspnet-same-runtime-version-2x/test.sh b/aspnet-same-runtime-version-2x/test.sh index 0f85b4f..0ad3c93 100755 --- a/aspnet-same-runtime-version-2x/test.sh +++ b/aspnet-same-runtime-version-2x/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - +IFS=$'\n\t' set -x # There's always a version of Microsoft.AspNetCore.App for each diff --git a/aspnet-same-runtime-version/test.sh b/aspnet-same-runtime-version/test.sh index 35a091d..2b536a9 100755 --- a/aspnet-same-runtime-version/test.sh +++ b/aspnet-same-runtime-version/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' # Check Microsoft.AspNetCore.App's version matches that of Microsoft.NETCore.App diff --git a/aspnetpatch-21/test.sh b/aspnetpatch-21/test.sh index 4e5e59e..330055a 100755 --- a/aspnetpatch-21/test.sh +++ b/aspnetpatch-21/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' set -x # Ensure we have an up-to-date value for latest_aspnet_package. diff --git a/bash-completion/test.sh b/bash-completion/test.sh index 3f63a1c..2b8f832 100755 --- a/bash-completion/test.sh +++ b/bash-completion/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" diff --git a/bundled-libunwind/test.sh b/bundled-libunwind/test.sh index 2210770..79920bc 100755 --- a/bundled-libunwind/test.sh +++ b/bundled-libunwind/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - +IFS=$'\n\t' set -x framework_dir=$(../dotnet-directory --framework "$1") diff --git a/cgroup-limit/test.sh b/cgroup-limit/test.sh index c3dc8c5..133be0e 100755 --- a/cgroup-limit/test.sh +++ b/cgroup-limit/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - +IFS=$'\n\t' set -x runtime_id="$(../runtime-id)" diff --git a/commit-ids-in-binaries/test.sh b/commit-ids-in-binaries/test.sh index 5f6bfb0..f2fc22c 100755 --- a/commit-ids-in-binaries/test.sh +++ b/commit-ids-in-binaries/test.sh @@ -12,7 +12,6 @@ set -euo pipefail IFS=$'\n\t' - set -x dotnet_home="$(dirname "$(readlink -f "$(command -v dotnet)")")" diff --git a/createdump-aspnet/test.sh b/createdump-aspnet/test.sh index c4634f9..8d6e1b5 100755 --- a/createdump-aspnet/test.sh +++ b/createdump-aspnet/test.sh @@ -2,7 +2,7 @@ # Enable "unofficial bash strict mode" set -euo pipefail - +IFS=$'\n\t' set -x IFS='.-' read -ra VERSION_SPLIT <<< "$1" diff --git a/distribution-packages/test.sh b/distribution-packages/test.sh index 63f7b21..a0e8f57 100755 --- a/distribution-packages/test.sh +++ b/distribution-packages/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - +IFS=$'\n\t' set -x sdk_version="$(dotnet --version)" diff --git a/dotnet-info-commit-ids/test.sh b/dotnet-info-commit-ids/test.sh index 7358001..daf9482 100755 --- a/dotnet-info-commit-ids/test.sh +++ b/dotnet-info-commit-ids/test.sh @@ -2,7 +2,7 @@ # unofficial bash strict mode set -euo pipefail - +IFS=$'\n\t' set -x dotnet --info diff --git a/dotnet-monitor-works/test.sh b/dotnet-monitor-works/test.sh index c135590..9bec9fe 100755 --- a/dotnet-monitor-works/test.sh +++ b/dotnet-monitor-works/test.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash set -euo pipefail -set -x IFS=$'\n\t' +set -x IFS='.-' read -ra VERSION_SPLIT <<< "$1" dotnet tool update -g dotnet-monitor --version "${VERSION_SPLIT[0]}.*-*" diff --git a/dotnet-trace/test.sh b/dotnet-trace/test.sh index 49d804d..d4f7173 100755 --- a/dotnet-trace/test.sh +++ b/dotnet-trace/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' set -x PROJNAME=dotnettrace diff --git a/extract-bundle-dir/test.sh b/extract-bundle-dir/test.sh index 0733c36..0ddc488 100755 --- a/extract-bundle-dir/test.sh +++ b/extract-bundle-dir/test.sh @@ -7,6 +7,7 @@ if [ -f /etc/profile ]; then fi set -euo pipefail +IFS=$'\n\t' # Verify DOTNET_BUNDLE_EXTRACT_BASE_DIR is set. if [[ "${DOTNET_BUNDLE_EXTRACT_BASE_DIR:-}" != "$HOME/.cache/dotnet_bundle_extract" ]]; then diff --git a/fdd-no-nuget/test.sh b/fdd-no-nuget/test.sh index b49b0f2..2db0ff1 100755 --- a/fdd-no-nuget/test.sh +++ b/fdd-no-nuget/test.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash -set +x +set -euo pipefail +IFS=$'\n\t' +set -x rm -rf ~/.nuget diff --git a/helloworld/test.sh b/helloworld/test.sh index 96458b1..f6d604e 100755 --- a/helloworld/test.sh +++ b/helloworld/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' PROJNAME=helloworld diff --git a/host-probes-rid-assets-legacy/test.sh b/host-probes-rid-assets-legacy/test.sh index 6897b22..a9bdebf 100755 --- a/host-probes-rid-assets-legacy/test.sh +++ b/host-probes-rid-assets-legacy/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euox pipefail +IFS=$'\n\t' # This test is testing the same functionality as host-probes-rid-assets # but when opting in to use the legacy graph (by setting System.Runtime.Loader.UseRidGraph=true). diff --git a/host-probes-rid-assets/test.sh b/host-probes-rid-assets/test.sh index 5ad21b2..c08433b 100755 --- a/host-probes-rid-assets/test.sh +++ b/host-probes-rid-assets/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euox pipefail +IFS=$'\n\t' # The lib project packages a native library in a rid-specific folder. # Only one rid is considered per nuget package. diff --git a/liblttng-ust_sys-sdt.h/test.sh b/liblttng-ust_sys-sdt.h/test.sh index cc9e2d9..f655035 100755 --- a/liblttng-ust_sys-sdt.h/test.sh +++ b/liblttng-ust_sys-sdt.h/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' set -x RUNTIME_ID=$(../runtime-id) diff --git a/libuv-kestrel-sample-app-2x/test.sh b/libuv-kestrel-sample-app-2x/test.sh index 24eaacf..ad4c6bf 100755 --- a/libuv-kestrel-sample-app-2x/test.sh +++ b/libuv-kestrel-sample-app-2x/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - +IFS=$'\n\t' set -x dotnet restore diff --git a/lttng/test.sh b/lttng/test.sh index 7a06aac..a86e826 100755 --- a/lttng/test.sh +++ b/lttng/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' SESSION_NAME=my-session TEST_FOLDER=/tmp/$SESSION_NAME diff --git a/man-pages/test.sh b/man-pages/test.sh index b06b41d..9fe57bc 100755 --- a/man-pages/test.sh +++ b/man-pages/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' helpPages=$(dotnet --help | grep -A 999 'SDK commands' | grep -E -B 999 'Common options|Additional commands' | awk 'NR>1 {print $1}' | head -n-2) diff --git a/nativeaot/test.sh b/nativeaot/test.sh index be42423..12d94fb 100755 --- a/nativeaot/test.sh +++ b/nativeaot/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - +IFS=$'\n\t' set -x rm -rf bin obj diff --git a/omnisharp/test.sh b/omnisharp/test.sh index e497539..f931bcc 100755 --- a/omnisharp/test.sh +++ b/omnisharp/test.sh @@ -2,7 +2,6 @@ set -euo pipefail IFS=$'\n\t' - set -x rm -rf workdir diff --git a/openssl-alpn/test.sh b/openssl-alpn/test.sh index 570d87f..c41daf7 100755 --- a/openssl-alpn/test.sh +++ b/openssl-alpn/test.sh @@ -3,6 +3,7 @@ # Make sure .NET Core has linked to SSL_*_alpn_* functions from OpenSSL set -euo pipefail +IFS=$'\n\t' set -x dotnet_dir="$(../dotnet-directory)" diff --git a/pgo-dynamic/test.sh b/pgo-dynamic/test.sh index d7040a6..d629562 100755 --- a/pgo-dynamic/test.sh +++ b/pgo-dynamic/test.sh @@ -3,7 +3,7 @@ # Check if the .NET Runtime can use dynamic PGO at runtime set -euo pipefail - +IFS=$'\n\t' set -x IFS='.-' read -ra VERSION <<< "$1" diff --git a/publish-aspnet-selfcontained/test.sh b/publish-aspnet-selfcontained/test.sh index 159b9c0..88c7955 100755 --- a/publish-aspnet-selfcontained/test.sh +++ b/publish-aspnet-selfcontained/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' set -x # Clear nuget sources to use the bundled runtime. diff --git a/publish-dotnet-selfcontained/test.sh b/publish-dotnet-selfcontained/test.sh index 0f0d7ef..2f1f309 100755 --- a/publish-dotnet-selfcontained/test.sh +++ b/publish-dotnet-selfcontained/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' set -x # Clear nuget sources to use the bundled runtime. diff --git a/publish-ready-to-run-linux/test.sh b/publish-ready-to-run-linux/test.sh index 42a044c..ae24352 100755 --- a/publish-ready-to-run-linux/test.sh +++ b/publish-ready-to-run-linux/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' set -x dotnet new console --no-restore diff --git a/publish-ready-to-run/test.sh b/publish-ready-to-run/test.sh index 03cacdd..8c10339 100755 --- a/publish-ready-to-run/test.sh +++ b/publish-ready-to-run/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' set -x dotnet new console --no-restore diff --git a/restore-with-rid/test.sh b/restore-with-rid/test.sh index d6581e8..b794348 100755 --- a/restore-with-rid/test.sh +++ b/restore-with-rid/test.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash set -euo pipefail +IFS=$'\n\t' set -x dotnet new console --no-restore diff --git a/system-data-odbc/test.sh b/system-data-odbc/test.sh index 7b2e494..b0a2f77 100755 --- a/system-data-odbc/test.sh +++ b/system-data-odbc/test.sh @@ -1,7 +1,7 @@ #!/bin/bash set -euo pipefail - +IFS=$'\n\t' set -x # This test *must* be run as non-root; postgresql will refuse to start as root. diff --git a/system-libunwind/test.sh b/system-libunwind/test.sh index c8213ba..1a99d30 100755 --- a/system-libunwind/test.sh +++ b/system-libunwind/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - +IFS=$'\n\t' set -x framework_dir=$(../dotnet-directory --framework "$1") diff --git a/system-openssl/test.sh b/system-openssl/test.sh index f526b14..78e9a3b 100755 --- a/system-openssl/test.sh +++ b/system-openssl/test.sh @@ -4,6 +4,7 @@ # using OpenSSL via dlopen (which is more likely to fail at runtime). set -euo pipefail +IFS=$'\n\t' set -x dotnet_dir="$(../dotnet-directory)" diff --git a/targeting-packs-bad-files/test.sh b/targeting-packs-bad-files/test.sh index 2e20b7c..9fe2fe6 100755 --- a/targeting-packs-bad-files/test.sh +++ b/targeting-packs-bad-files/test.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -euo pipefail - +IFS=$'\n\t' set -x dotnet_dir=$(dirname "$(readlink -f "$(command -v dotnet)")") diff --git a/telemetry-is-off-by-default/test-telemetry-tcpdump.sh b/telemetry-is-off-by-default/test-telemetry-tcpdump.sh index d391c5d..d7d49a9 100755 --- a/telemetry-is-off-by-default/test-telemetry-tcpdump.sh +++ b/telemetry-is-off-by-default/test-telemetry-tcpdump.sh @@ -4,6 +4,7 @@ set -euo pipefail set -x +IFS=$'\n\t' # found via experimentation telemetry_host=dc.services.visualstudio.com diff --git a/telemetry-is-off-by-default/test.sh b/telemetry-is-off-by-default/test.sh index 232d45c..fdad464 100755 --- a/telemetry-is-off-by-default/test.sh +++ b/telemetry-is-off-by-default/test.sh @@ -9,6 +9,7 @@ # access. set -euo pipefail +IFS=$'\n\t' set -x no_server=("/nodeReuse:false" "/p:UseSharedCompilation=false" "/p:UseRazorBuildServer=false") diff --git a/template-test/test.sh b/template-test/test.sh index 0408f40..4df642e 100755 --- a/template-test/test.sh +++ b/template-test/test.sh @@ -4,7 +4,8 @@ # dotnet new