mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 16:49:41 +00:00
Merge pull request #247 from JackPhallen/feat/more-purge-support
feat(purge): C# bin purge support
This commit is contained in:
@@ -547,3 +547,97 @@ EOF
|
||||
|
||||
[ -d "$HOME/.cache/mole" ] || [ -d "${XDG_CACHE_HOME:-$HOME/.cache}/mole" ]
|
||||
}
|
||||
|
||||
# .NET bin directory detection tests
|
||||
@test "is_dotnet_bin_dir: finds .NET context in parent directory with Debug dir" {
|
||||
mkdir -p "$HOME/www/dotnet-app/bin/Debug"
|
||||
touch "$HOME/www/dotnet-app/MyProject.csproj"
|
||||
|
||||
result=$(bash -c "
|
||||
source '$PROJECT_ROOT/lib/clean/project.sh'
|
||||
if is_dotnet_bin_dir '$HOME/www/dotnet-app/bin'; then
|
||||
echo 'FOUND'
|
||||
else
|
||||
echo 'NOT_FOUND'
|
||||
fi
|
||||
")
|
||||
|
||||
[[ "$result" == "FOUND" ]]
|
||||
}
|
||||
|
||||
@test "is_dotnet_bin_dir: requires .csproj AND Debug/Release" {
|
||||
mkdir -p "$HOME/www/dotnet-app/bin"
|
||||
touch "$HOME/www/dotnet-app/MyProject.csproj"
|
||||
|
||||
result=$(bash -c "
|
||||
source '$PROJECT_ROOT/lib/clean/project.sh'
|
||||
if is_dotnet_bin_dir '$HOME/www/dotnet-app/bin'; then
|
||||
echo 'FOUND'
|
||||
else
|
||||
echo 'NOT_FOUND'
|
||||
fi
|
||||
")
|
||||
|
||||
# Should not find it because Debug/Release directories don't exist
|
||||
[[ "$result" == "NOT_FOUND" ]]
|
||||
}
|
||||
|
||||
@test "is_dotnet_bin_dir: rejects non-bin directories" {
|
||||
mkdir -p "$HOME/www/dotnet-app/obj"
|
||||
touch "$HOME/www/dotnet-app/MyProject.csproj"
|
||||
|
||||
result=$(bash -c "
|
||||
source '$PROJECT_ROOT/lib/clean/project.sh'
|
||||
if is_dotnet_bin_dir '$HOME/www/dotnet-app/obj'; then
|
||||
echo 'FOUND'
|
||||
else
|
||||
echo 'NOT_FOUND'
|
||||
fi
|
||||
")
|
||||
[[ "$result" == "NOT_FOUND" ]]
|
||||
}
|
||||
|
||||
|
||||
# Integration test for bin scanning
|
||||
@test "scan_purge_targets: includes .NET bin directories with Debug/Release" {
|
||||
mkdir -p "$HOME/www/dotnet-app/bin/Debug"
|
||||
touch "$HOME/www/dotnet-app/MyProject.csproj"
|
||||
|
||||
local scan_output
|
||||
scan_output="$(mktemp)"
|
||||
|
||||
result=$(bash -c "
|
||||
source '$PROJECT_ROOT/lib/clean/project.sh'
|
||||
scan_purge_targets '$HOME/www' '$scan_output'
|
||||
if grep -q '$HOME/www/dotnet-app/bin' '$scan_output'; then
|
||||
echo 'FOUND'
|
||||
else
|
||||
echo 'MISSING'
|
||||
fi
|
||||
")
|
||||
|
||||
rm -f "$scan_output"
|
||||
|
||||
[[ "$result" == "FOUND" ]]
|
||||
}
|
||||
|
||||
@test "scan_purge_targets: skips generic bin directories (non-.NET)" {
|
||||
mkdir -p "$HOME/www/ruby-app/bin"
|
||||
touch "$HOME/www/ruby-app/Gemfile"
|
||||
|
||||
local scan_output
|
||||
scan_output="$(mktemp)"
|
||||
|
||||
result=$(bash -c "
|
||||
source '$PROJECT_ROOT/lib/clean/project.sh'
|
||||
scan_purge_targets '$HOME/www' '$scan_output'
|
||||
if grep -q '$HOME/www/ruby-app/bin' '$scan_output'; then
|
||||
echo 'FOUND'
|
||||
else
|
||||
echo 'SKIPPED'
|
||||
fi
|
||||
")
|
||||
|
||||
rm -f "$scan_output"
|
||||
[[ "$result" == "SKIPPED" ]]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user