@@ -1245,10 +1245,138 @@ jobs:
12451245 exit 1
12461246 fi
12471247
1248+ l10n_locale_embedding_cargo_install :
1249+ name : L10n/Locale Embedding - Cargo Install
1250+ runs-on : ubuntu-latest
1251+ env :
1252+ SCCACHE_GHA_ENABLED : " true"
1253+ RUSTC_WRAPPER : " sccache"
1254+ steps :
1255+ - uses : actions/checkout@v5
1256+ with :
1257+ persist-credentials : false
1258+ - uses : dtolnay/rust-toolchain@stable
1259+ - uses : Swatinem/rust-cache@v2
1260+ with :
1261+ key : cargo-install-locale-embedding
1262+ - name : Run sccache-cache
1263+ uses :
mozilla-actions/[email protected] 1264+ - name : Install prerequisites
1265+ run : |
1266+ sudo apt-get -y update
1267+ sudo apt-get -y install libselinux1-dev locales
1268+ # Generate French locale for testing
1269+ sudo locale-gen --keep-existing fr_FR.UTF-8
1270+ locale -a | grep -i fr || exit 1
1271+
1272+ - name : Test English locale embedding (default)
1273+ run : |
1274+ export LANG=en_US.UTF-8
1275+ export LC_ALL=en_US.UTF-8
1276+
1277+ echo "Building uu_yes with LANG=$LANG"
1278+ cargo build --package uu_yes --release
1279+
1280+ # Find the generated embedded_locales.rs
1281+ locale_file=$(find target/release/build -path "*/uu_yes-*/out/embedded_locales.rs" -o -path "*/uucore-*/out/embedded_locales.rs" | head -1)
1282+ if [ -z "$locale_file" ]; then
1283+ echo "ERROR: Could not find embedded_locales.rs"
1284+ exit 1
1285+ fi
1286+
1287+ echo "Found embedded_locales.rs at: $locale_file"
1288+ echo "Checking embedded locales..."
1289+
1290+ # Should contain en-US
1291+ if grep -q 'yes/en-US\.ftl' "$locale_file" || grep -q 'uucore/en-US\.ftl' "$locale_file"; then
1292+ echo "✓ Found en-US locale (fallback)"
1293+ else
1294+ echo "✗ ERROR: en-US locale not found"
1295+ exit 1
1296+ fi
1297+
1298+ # Should NOT contain fr-FR when building with en_US.UTF-8
1299+ if grep -q 'yes/fr-FR\.ftl' "$locale_file" || grep -q 'uucore/fr-FR\.ftl' "$locale_file"; then
1300+ echo "✗ ERROR: Unexpectedly found fr-FR locale when LANG=en_US.UTF-8"
1301+ exit 1
1302+ else
1303+ echo "✓ Correctly omitted fr-FR locale"
1304+ fi
1305+
1306+ echo "✓ SUCCESS: English locale embedding working correctly"
1307+
1308+ - name : Test French locale embedding (system locale)
1309+ run : |
1310+ export LANG=fr_FR.UTF-8
1311+ export LC_ALL=fr_FR.UTF-8
1312+
1313+ # Clean previous build to ensure fresh compile
1314+ cargo clean -p uu_yes
1315+ cargo clean -p uucore
1316+
1317+ echo "Building uu_yes with LANG=$LANG"
1318+ cargo build --package uu_yes --release
1319+
1320+ # Find the generated embedded_locales.rs
1321+ locale_file=$(find target/release/build -path "*/uu_yes-*/out/embedded_locales.rs" -o -path "*/uucore-*/out/embedded_locales.rs" | head -1)
1322+ if [ -z "$locale_file" ]; then
1323+ echo "ERROR: Could not find embedded_locales.rs"
1324+ exit 1
1325+ fi
1326+
1327+ echo "Found embedded_locales.rs at: $locale_file"
1328+ echo "Checking embedded locales..."
1329+
1330+ # Should contain en-US (fallback)
1331+ if grep -q 'yes/en-US\.ftl' "$locale_file" || grep -q 'uucore/en-US\.ftl' "$locale_file"; then
1332+ echo "✓ Found en-US locale (fallback)"
1333+ else
1334+ echo "✗ ERROR: en-US locale not found"
1335+ exit 1
1336+ fi
1337+
1338+ # Should contain fr-FR when building with fr_FR.UTF-8
1339+ if grep -q 'yes/fr-FR\.ftl' "$locale_file" || grep -q 'uucore/fr-FR\.ftl' "$locale_file"; then
1340+ echo "✓ Found fr-FR locale (system locale from LANG)"
1341+ else
1342+ echo "Note: fr-FR locale not found - this is expected if French translation doesn't exist yet"
1343+ echo "::notice::French locale for 'yes' utility may not be available"
1344+ fi
1345+
1346+ echo "✓ SUCCESS: System locale detection working correctly"
1347+
1348+ - name : Test locale count is reasonable
1349+ run : |
1350+ export LANG=fr_FR.UTF-8
1351+ cargo clean -p uu_yes
1352+ cargo build --package uu_yes --release
1353+
1354+ locale_file=$(find target/release/build -path "*/uucore-*/out/embedded_locales.rs" | head -1)
1355+ if [ -z "$locale_file" ]; then
1356+ echo "ERROR: Could not find uucore embedded_locales.rs"
1357+ exit 1
1358+ fi
1359+
1360+ # Count embedded locales (should be en-US + system locale, not all locales)
1361+ locale_count=$(grep -c '/en-US\.ftl\|/fr-FR\.ftl' "$locale_file" || echo "0")
1362+ echo "uu_yes has $locale_count embedded locale entries for yes utility"
1363+
1364+ # For a single utility build, should have minimal locales (en-US + optionally system locale)
1365+ # Not the full multicall set
1366+ total_match_count=$(grep -c '=> Some(r###' "$locale_file" || echo "0")
1367+ echo "Total embedded entries: $total_match_count"
1368+
1369+ if [ "$total_match_count" -le 10 ]; then
1370+ echo "✓ SUCCESS: Locale embedding is targeted ($total_match_count entries)"
1371+ else
1372+ echo "::warning::More locales than expected ($total_match_count entries)"
1373+ echo "This might be expected for utility + uucore locales"
1374+ fi
1375+
12481376 l10n_locale_embedding_regression_test :
12491377 name : L10n/Locale Embedding Regression Test
12501378 runs-on : ubuntu-latest
1251- needs : [l10n_locale_embedding_cat, l10n_locale_embedding_ls, l10n_locale_embedding_multicall]
1379+ needs : [l10n_locale_embedding_cat, l10n_locale_embedding_ls, l10n_locale_embedding_multicall, l10n_locale_embedding_cargo_install ]
12521380 steps :
12531381 - name : All locale embedding tests passed
12541382 run : echo "✓ All locale embedding tests passed successfully"
0 commit comments