Skip to content

Commit eaf5498

Browse files
committed
Fix for testing with rockylinux and addition in tests
1 parent d337166 commit eaf5498

14 files changed

Lines changed: 146 additions & 10 deletions

src/rust/install.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,8 @@ if [ "${CUSTOM_COMPONENTS}" = "true" ] && [ -n "${RUST_COMPONENTS}" ]; then
401401
echo "Installing custom Rust components..."
402402
IFS=',' read -ra components <<< "${RUST_COMPONENTS}"
403403
for component in "${components[@]}"; do
404-
# Trim whitespace
405-
component=$(echo "${component}" | xargs)
404+
# Trim leading and trailing whitespace
405+
component="${component#"${component%%[![:space:]]*}"}" && component="${component%"${component##*[![:space:]]}"}"
406406
if [ -n "${component}" ]; then
407407
echo "Installing Rust component: ${component}"
408408
if ! rustup component add "${component}" 2>&1; then

test/rust/rust_with_almalinux_8.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,27 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8+
# Helper function to check component is installed
9+
check_component_installed() {
10+
local component=$1
11+
if rustup component list | grep -q "${component}.*installed"; then
12+
return 0 # Component is installed (success)
13+
else
14+
return 1 # Component is not installed (failure)
15+
fi
16+
}
17+
818
# Definition specific tests
919
check "cargo version" cargo --version
1020
check "rustc version" rustc --version
1121
check "correct rust version" rustup target list | grep aarch64-unknown-linux-gnu
1222

23+
# Check that all specified extended components are installed
24+
check "rust-analyzer is installed" check_component_installed "rust-analyzer"
25+
check "rust-src is installed" check_component_installed "rust-src"
26+
check "rustfmt is installed" check_component_installed "rustfmt"
27+
check "clippy is installed" check_component_installed "clippy"
28+
check "rust-docs is installed" check_component_installed "rust-docs"
1329

1430
# Report result
1531
reportResults

test/rust/rust_with_almalinux_9.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,27 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8+
# Helper function to check component is installed
9+
check_component_installed() {
10+
local component=$1
11+
if rustup component list | grep -q "${component}.*installed"; then
12+
return 0 # Component is installed (success)
13+
else
14+
return 1 # Component is not installed (failure)
15+
fi
16+
}
17+
818
# Definition specific tests
919
check "cargo version" cargo --version
1020
check "rustc version" rustc --version
1121
check "correct rust version" rustup target list | grep aarch64-unknown-linux-gnu
1222

23+
# Check that all specified extended components are installed
24+
check "rust-analyzer is installed" check_component_installed "rust-analyzer"
25+
check "rust-src is installed" check_component_installed "rust-src"
26+
check "rustfmt is installed" check_component_installed "rustfmt"
27+
check "clippy is installed" check_component_installed "clippy"
28+
check "rust-docs is installed" check_component_installed "rust-docs"
1329

1430
# Report result
1531
reportResults

test/rust/rust_with_centos.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,27 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8+
# Helper function to check component is installed
9+
check_component_installed() {
10+
local component=$1
11+
if rustup component list | grep -q "${component}.*installed"; then
12+
return 0 # Component is installed (success)
13+
else
14+
return 1 # Component is not installed (failure)
15+
fi
16+
}
17+
818
# Definition specific tests
919
check "cargo version" cargo --version
1020
check "rustc version" rustc --version
1121
check "correct rust version" rustup target list | grep aarch64-unknown-linux-gnu
1222

23+
# Check that all specified extended components are installed
24+
check "rust-analyzer is installed" check_component_installed "rust-analyzer"
25+
check "rust-src is installed" check_component_installed "rust-src"
26+
check "rustfmt is installed" check_component_installed "rustfmt"
27+
check "clippy is installed" check_component_installed "clippy"
28+
check "rust-docs is installed" check_component_installed "rust-docs"
1329

1430
# Report result
1531
reportResults

test/rust/rust_with_custom_components.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ check_component_not_installed() {
2828
# Definition specific tests
2929
check "cargo version" cargo --version
3030
check "rustc version" rustc --version
31+
check "correct rust version" rustup target list | grep aarch64-unknown-linux-gnu
3132

3233
# Check that specified custom components are installed
3334
check "rust-analyzer is installed" check_component_installed "rust-analyzer"

test/rust/rust_with_default_components.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ check_component_installed() {
1818
# Definition specific tests
1919
check "cargo version" cargo --version
2020
check "rustc version" rustc --version
21+
check "correct rust version" rustup target list | grep aarch64-unknown-linux-gnu
2122

2223
# Check that default components are installed
2324
check "rust-analyzer is installed" check_component_installed "rust-analyzer"

test/rust/rust_with_empty_components.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ check_component_not_installed() {
2828
# Definition specific tests
2929
check "cargo version" cargo --version
3030
check "rustc version" rustc --version
31+
check "correct rust version" rustup target list | grep aarch64-unknown-linux-gnu
3132

3233
# Check that no additional components are installed when empty list is provided
3334
# Only the basic rust toolchain should be available

test/rust/rust_with_extended_components.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ check_component_installed() {
1818
# Definition specific tests
1919
check "cargo version" cargo --version
2020
check "rustc version" rustc --version
21+
check "correct rust version" rustup target list | grep aarch64-unknown-linux-gnu
2122

2223
# Check that all specified extended components are installed
2324
check "rust-analyzer is installed" check_component_installed "rust-analyzer"

test/rust/rust_with_fedora.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,27 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8+
# Helper function to check component is installed
9+
check_component_installed() {
10+
local component=$1
11+
if rustup component list | grep -q "${component}.*installed"; then
12+
return 0 # Component is installed (success)
13+
else
14+
return 1 # Component is not installed (failure)
15+
fi
16+
}
17+
818
# Definition specific tests
919
check "cargo version" cargo --version
1020
check "rustc version" rustc --version
1121
check "correct rust version" rustup target list | grep aarch64-unknown-linux-gnu
1222

23+
# Check that all specified extended components are installed
24+
check "rust-analyzer is installed" check_component_installed "rust-analyzer"
25+
check "rust-src is installed" check_component_installed "rust-src"
26+
check "rustfmt is installed" check_component_installed "rustfmt"
27+
check "clippy is installed" check_component_installed "clippy"
28+
check "rust-docs is installed" check_component_installed "rust-docs"
1329

1430
# Report result
1531
reportResults

test/rust/rust_with_mariner.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,27 @@ set -e
55
# Optional: Import test library
66
source dev-container-features-test-lib
77

8+
# Helper function to check component is installed
9+
check_component_installed() {
10+
local component=$1
11+
if rustup component list | grep -q "${component}.*installed"; then
12+
return 0 # Component is installed (success)
13+
else
14+
return 1 # Component is not installed (failure)
15+
fi
16+
}
17+
818
# Definition specific tests
919
check "cargo version" cargo --version
1020
check "rustc version" rustc --version
1121
check "correct rust version" rustup target list | grep aarch64-unknown-linux-gnu
1222

23+
# Check that all specified extended components are installed
24+
check "rust-analyzer is installed" check_component_installed "rust-analyzer"
25+
check "rust-src is installed" check_component_installed "rust-src"
26+
check "rustfmt is installed" check_component_installed "rustfmt"
27+
check "clippy is installed" check_component_installed "clippy"
28+
check "rust-docs is installed" check_component_installed "rust-docs"
1329

1430
# Report result
1531
reportResults

0 commit comments

Comments
 (0)