Skip to content

Commit

Permalink
ci: debug fs-trim failures
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Nov 29, 2024
1 parent f8eb322 commit dcb21f4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion commands/dorothy
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,7 @@ function dorothy_() (
# pre-requisites
assert_dorothy_configured
# ^ no need for user config for tests
local only=("$@") flakey=('config-helper' 'echo-wait') skips=('dorothy' 'bash.bash') no_bash_v3=('get-installer' 'dorothy-config')
local only=("$@" 'fs-structure' 'fs-trim') flakey=('config-helper' 'echo-wait') skips=('dorothy' 'bash.bash') no_bash_v3=('get-installer' 'dorothy-config')

# action
echo-style --h1='Dorothy Tests'
Expand Down
22 changes: 21 additions & 1 deletion commands/fs-structure
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
#!/usr/bin/env bash

function fs_structure_test() (
source "$DOROTHY/sources/bash.bash"
echo-style --h1="TEST: $0"

fs-structure
fs-structure --no-eza

fs-structure -- .
fs-structure --no-eza -- .

fs-structure -- "$DOROTHY"
fs-structure --no-eza -- "$DOROTHY"

echo-style --g1="TEST: $0"
return 0
)
function fs_structure() (
source "$DOROTHY/sources/bash.bash"

Expand Down Expand Up @@ -188,5 +204,9 @@ function fs_structure() (

# fire if invoked standalone
if [[ $0 == "${BASH_SOURCE[0]}" ]]; then
fs_structure "$@"
if [[ $* == '--test' ]]; then
fs_structure_test
else
fs_structure "$@"
fi
fi
26 changes: 15 additions & 11 deletions commands/fs-trim
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,15 @@ function fs_trim() (
esac
done

# verify
# check
if [[ ${#option_inputs[@]} -eq 0 ]]; then
option_inputs+=("$(pwd)")
# help 'No <path>s provided.'
option_inputs+=('.')
fi

# verify
set -x

# =====================================
# Action

Expand All @@ -223,13 +227,13 @@ function fs_trim() (

# helpers
function __confirm {
local input="$1" title body
local path="$1" title body
if [[ $option_confirm == 'yes' ]]; then
title="$(
echo-style --notice1='What items do you wish to trim for:' --newline \
--code-notice1="$(fs-absolute -- "$input")"
--code-notice1="$(fs-absolute -- "$path")"
)"
body="$(echo-style --reset)$(fs-structure --sudo="$option_sudo" --user="$option_user" --group="$option_group" -- "$input")"
body="$(echo-style --reset)$(fs-structure --sudo="$option_sudo" --user="$option_user" --group="$option_group" -- "$path")"
mapfile -t selection < <(
choose "$title" "$body" --truncate-body --multiple --defaults-exact="$(__print_lines "${selection[@]}")" --label -- \
cache "Caches: $(echo-style --newline --dim="${cache_filenames[*]}")" \
Expand Down Expand Up @@ -261,22 +265,22 @@ function fs_trim() (
local path="$1" refresh='yes'
while [[ $refresh == 'yes' ]]; do
refresh='no'
if is-not-directory --sudo="$option_sudo" --user="$option_user" --group="$option_group" -- "$input"; then
if is-not-directory --sudo="$option_sudo" --user="$option_user" --group="$option_group" -- "$path"; then
break
fi
if [[ $option_cache == 'yes' ]] && __wrap find "$path" \( "${cache_find[@]}" \) -delete -print | eval-on-empty-stdin -- false >/dev/null; then
if [[ $option_cache == 'yes' ]] && __wrap find "$path" \( "${cache_find[@]}" \) -delete -print | eval-on-empty-stdin -- false; then
refresh='yes'
fi
if [[ $option_module == 'yes' ]] && __wrap find "$path" \( "${module_find[@]}" \) -delete -print | eval-on-empty-stdin -- false >/dev/null; then
if [[ $option_module == 'yes' ]] && __wrap find "$path" \( "${module_find[@]}" \) -delete -print | eval-on-empty-stdin -- false; then
refresh='yes'
fi
if [[ $option_empty_files == 'yes' ]] && __wrap find "$path" -type f -empty -delete -print | eval-on-empty-stdin -- false >/dev/null; then
if [[ $option_empty_files == 'yes' ]] && __wrap find "$path" -type f -empty -delete -print | eval-on-empty-stdin -- false; then
refresh='yes'
fi
if [[ $option_broken_symlinks == 'yes' ]] && __wrap find "$path" -type l -exec fs-trim-symlinks.bash -- {} + | eval-on-empty-stdin -- false >/dev/null; then
if [[ $option_broken_symlinks == 'yes' ]] && __wrap find "$path" -type l -exec fs-trim-symlinks.bash -- {} + | eval-on-empty-stdin -- false; then
refresh='yes'
fi
if [[ $option_empty_directories == 'yes' ]] && __wrap find "$path" -type d -empty -delete -print | eval-on-empty-stdin -- false >/dev/null; then
if [[ $option_empty_directories == 'yes' ]] && __wrap find "$path" -type d -empty -delete -print | eval-on-empty-stdin -- false; then
refresh='yes'
fi
done
Expand Down

0 comments on commit dcb21f4

Please sign in to comment.