mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-08-18 05:37:53 +00:00

When testing ingest tests, one often wants to keep the .json output or generated metrics files around for inspection after the fact. This updates the bash condition to actually honor the comment that mentions # export UNSTRUCTURED_CLEANUP_DEV_FIXTURES=1 ** Test Instructions ** Run: export UNSTRUCTURED_CLEANUP_DEV_FIXTURES=1 ./test_unstructured_ingest/src/s3.sh ./test_unstructured_ingest/evaluation-metrics.sh text-extraction and witness test directories/files do not get cleaned up. E.g., `test_unstructured_ingest/metrics-tmp/`. One can also add a `set -x` at the top of test_unstructured_ingest/cleanup.sh to see what is getting skipped (it's a lot!).
24 lines
673 B
Bash
24 lines
673 B
Bash
#!/usr/bin/env bash
|
|
|
|
|
|
function cleanup_dir() {
|
|
# NOTE(crag): for developers that want to always clean up .json outputs, etc., set
|
|
# export UNSTRUCTURED_CLEANUP_DEV_FIXTURES=1
|
|
if [ "$CI" != "true" ] && \
|
|
[ -n "$UNSTRUCTURED_CLEANUP_DEV_FIXTURES" ] && \
|
|
[ "$UNSTRUCTURED_CLEANUP_DEV_FIXTURES" != "0" ] ; then
|
|
return 0
|
|
fi
|
|
local dir_to_cleanup="${1}"
|
|
echo "--- Running cleanup of $dir_to_cleanup ---"
|
|
|
|
if [ -d "$dir_to_cleanup" ]; then
|
|
echo "cleaning up directory: $dir_to_cleanup"
|
|
rm -rf "$dir_to_cleanup"
|
|
else
|
|
echo "$dir_to_cleanup does not exist or is not a directory, skipping deletion"
|
|
fi
|
|
|
|
echo "--- Cleanup done ---"
|
|
}
|