Fixed up the output of the 'uuids_to_keep' case

pull/959/head
Morgan Pretty 3 months ago
parent 91998a1717
commit d11b4d7ac6

@ -231,6 +231,7 @@ local unit_test_summary = {
{
name: 'Install Codecov CLI',
commands: [
'mkdir -p build/artifacts',
'pip3 install codecov-cli 2>&1 | grep "The script codecovcli is installed in" | sed -n -e "s/^.*The script codecovcli is installed in //p" | sed -n -e "s/ which is not on PATH.$//p" > ./build/artifacts/codecov_install_path',
|||
if [[ ! -s ./build/artifacts/codecov_install_path ]]; then

@ -26,10 +26,14 @@ xcrun simctl delete unavailable
# Extract all UUIDs from the device_set
uuids=$(grep -Eo '[A-F0-9]{8}-([A-F0-9]{4}-){3}[A-F0-9]{12}' "$plist")
running_uuids=$(xcrun simctl list devices | grep -Eo '[A-F0-9]{8}-([A-F0-9]{4}-){3}[A-F0-9]{12}' | grep -v 'Shutdown')
# Get the current time in minutes since 1970-01-01 00:00:00 UTC
current_time=$(date +%s)
current_time=$((current_time / 60))
# Create empty arrays to store the outputs
uuids_to_leave=()
uuids_to_keep=()
uuids_to_ignore=()
uuids_to_remove=()
# Find directories older than an hour
@ -37,13 +41,24 @@ while read -r dir; do
# Get the last component of the directory path
dir_name=$(basename "$dir")
# Check if the directory name is in the list of UUIDs
# Get the modification time of the folder in minutes since 1970-01-01 00:00:00 UTC
folder_time=$(stat -f "%m" "$dir")
folder_time=$((folder_time / 60))
# Check if the folder is in the uuids array
if ! echo "$uuids" | grep -q "$dir_name"; then
uuids_to_remove+=("$dir_name")
if ((current_time - folder_time <= 60)); then
# If the folder was created within the past 60 minutes, add it to uuids_to_keep
uuids_to_keep+=("$dir_name")
else
# If the folder was created longer than 60 minutes ago, add it to uuids_to_remove
uuids_to_remove+=("$dir_name")
fi
else
uuids_to_leave+=("$dir_name")
# If the folder is in the uuids array, add it to uuids_to_ignore
uuids_to_ignore+=("$dir_name")
fi
done < <(find "$dir" -maxdepth 1 -type d -not -path "$dir" -mmin +60)
done < <(find "$dir" -maxdepth 1 -type d -not -path "$dir")
# Delete the simulators
if [ ${#uuids_to_remove[@]} -eq 0 ]; then
@ -57,7 +72,6 @@ else
fi
# Output the pipeline simulators we are leaving
uuids_to_keep=$(echo "$uuids" | grep -v "${uuids_to_leave[*]}" | grep -v "${uuids_to_remove[*]}")
if [ ${#uuids_to_keep[@]} -gt 0 ]; then
echo -e "\e[33m\nIgnoring ${#uuids_to_keep[@]} test simulators (might be in use):\e[0m"
for uuid in "${uuids_to_keep[@]}"; do
@ -66,7 +80,7 @@ if [ ${#uuids_to_keep[@]} -gt 0 ]; then
fi
# Output the remaining Xcode Simulators
echo -e "\e[32m\nIgnoring ${#uuids_to_leave[@]} Xcode simulators:\e[0m"
for uuid in "${uuids_to_leave[@]}"; do
echo -e "\e[32m\nIgnoring ${#uuids_to_ignore[@]} Xcode simulators:\e[0m"
for uuid in "${uuids_to_ignore[@]}"; do
echo -e "\e[32m $uuid\e[0m"
done
Loading…
Cancel
Save