Skip to content

Commit ebe712f

Browse files
committed
check cargo install in the CI too
1 parent 019c26e commit ebe712f

1 file changed

Lines changed: 147 additions & 0 deletions

File tree

.github/workflows/l10n.yml

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,153 @@ jobs:
11181118
env:
11191119
RUST_BACKTRACE: "1"
11201120

1121+
l10n_cargo_install_regression_test:
1122+
name: L10n/Cargo Install Regression Test
1123+
runs-on: ubuntu-latest
1124+
env:
1125+
SCCACHE_GHA_ENABLED: "true"
1126+
RUSTC_WRAPPER: "sccache"
1127+
steps:
1128+
- uses: actions/checkout@v5
1129+
with:
1130+
persist-credentials: false
1131+
- uses: dtolnay/rust-toolchain@stable
1132+
- uses: Swatinem/rust-cache@v2
1133+
- name: Run sccache-cache
1134+
uses: mozilla-actions/sccache-action@v0.0.9
1135+
- name: Install/setup prerequisites
1136+
shell: bash
1137+
run: |
1138+
## Install/setup prerequisites
1139+
sudo apt-get -y update ; sudo apt-get -y install libselinux1-dev build-essential
1140+
- name: Test cargo install locale functionality for individual utilities
1141+
shell: bash
1142+
run: |
1143+
## Test that individual utilities installed via cargo install have proper locale support
1144+
echo "Testing cargo install locale functionality regression..."
1145+
1146+
# Create temporary install directory
1147+
INSTALL_DIR="$(pwd)/test-install-dir"
1148+
mkdir -p "$INSTALL_DIR"
1149+
1150+
# Get all utilities with locales
1151+
utilities_to_test=()
1152+
for util in $(bash util/show-utils.sh); do
1153+
if [ -d "src/uu/$util/locales" ]; then
1154+
utilities_to_test+=("$util")
1155+
fi
1156+
done
1157+
1158+
echo "Testing ${#utilities_to_test[@]} utilities with locales: ${utilities_to_test[*]}"
1159+
1160+
# Test each utility
1161+
for util in "${utilities_to_test[@]}"; do
1162+
echo "Testing cargo install for $util..."
1163+
1164+
# Install the utility
1165+
cargo install --path "src/uu/$util" --root "$INSTALL_DIR" --force --quiet
1166+
1167+
# Test that the binary exists and runs
1168+
binary_path="$INSTALL_DIR/bin/$util"
1169+
if [ -f "$binary_path" ]; then
1170+
echo "✓ $util binary installed successfully"
1171+
1172+
# Test --help doesn't show locale errors
1173+
help_output=$("$binary_path" --help 2>&1)
1174+
help_exit_code=$?
1175+
1176+
if [ $help_exit_code -eq 0 ]; then
1177+
echo "✓ $util --help executes successfully"
1178+
1179+
# Check for locale error messages that indicate regression
1180+
if echo "$help_output" | grep -q "Could not init the localization system"; then
1181+
echo "✗ ERROR: $util shows locale initialization error - this is a REGRESSION"
1182+
echo "Help output: $help_output"
1183+
exit 1
1184+
elif echo "$help_output" | grep -q "Locales directory not found"; then
1185+
echo "✗ ERROR: $util shows locale directory error - this is a REGRESSION"
1186+
echo "Help output: $help_output"
1187+
exit 1
1188+
else
1189+
echo "✓ $util locale functionality working (no error messages)"
1190+
fi
1191+
1192+
# For utilities we know work well, check for proper English text
1193+
case "$util" in
1194+
"yes")
1195+
if echo "$help_output" | grep -q "Repeatedly display a line with STRING"; then
1196+
echo "✓ $util shows proper English help text"
1197+
else
1198+
echo "⚠ $util help text may not be fully localized, but no errors detected"
1199+
fi
1200+
;;
1201+
"touch")
1202+
if echo "$help_output" | grep -q -E "(Update|change) .* access.* modifi"; then
1203+
echo "✓ $util shows proper English help text"
1204+
else
1205+
echo "⚠ $util help text may not be fully localized, but no errors detected"
1206+
fi
1207+
;;
1208+
*)
1209+
echo "✓ $util executed without locale errors (content not validated)"
1210+
;;
1211+
esac
1212+
else
1213+
echo "✗ ERROR: $util --help failed with exit code $help_exit_code"
1214+
echo "Help output: $help_output"
1215+
exit 1
1216+
fi
1217+
1218+
# Test basic functionality
1219+
case "$util" in
1220+
"yes")
1221+
# Test that yes produces output
1222+
yes_output=$(timeout 1s "$binary_path" test 2>/dev/null || true)
1223+
if echo "$yes_output" | grep -q "test"; then
1224+
echo "✓ $util basic functionality works"
1225+
else
1226+
echo "✗ ERROR: $util basic functionality failed"
1227+
exit 1
1228+
fi
1229+
;;
1230+
"touch")
1231+
# Test that touch can create a file
1232+
temp_file="$(mktemp)"
1233+
rm -f "$temp_file"
1234+
if "$binary_path" "$temp_file" && [ -f "$temp_file" ]; then
1235+
echo "✓ $util basic functionality works"
1236+
rm -f "$temp_file"
1237+
else
1238+
echo "✗ ERROR: $util basic functionality failed"
1239+
exit 1
1240+
fi
1241+
;;
1242+
*)
1243+
# For other utilities, just test --version
1244+
if "$binary_path" --version >/dev/null 2>&1; then
1245+
echo "✓ $util --version works"
1246+
else
1247+
echo "✗ ERROR: $util --version failed"
1248+
exit 1
1249+
fi
1250+
;;
1251+
esac
1252+
else
1253+
echo "✗ ERROR: $util binary not found after cargo install"
1254+
exit 1
1255+
fi
1256+
else
1257+
echo "Skipping $util (no locales directory)"
1258+
fi
1259+
echo
1260+
done
1261+
1262+
echo "✓ All cargo install locale functionality tests passed"
1263+
echo "This confirms that individual utilities can be installed via cargo install without locale regression"
1264+
1265+
# Clean up
1266+
rm -rf "$INSTALL_DIR"
1267+
11211268
l10n_locale_embedding_regression_test:
11221269
name: L10n/Locale Embedding Regression Test
11231270
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)