mirror of
https://github.com/Unstructured-IO/unstructured.git
synced 2025-07-24 17:41:15 +00:00

- parametrize the output folder paths and expected output folder paths in comparison scripts - now allow user to use env `OUTPUT_ROOT` to control where the output and expected output is - currently assumes output from test and expected output are in the same directory; this may need separation later ## test run ```bash OUTPUT_ROOT=/tmp ./test_unstructured_ingest/test-ingest-src.sh ``` and it should show files changed but not able to show diff since there is no expected output content at `OUTPUT_ROOT`. Then run ```bash cp -R test_unstructured_ingest/expected-* /tmp/ OUTPUT_ROOT=/tmp ./test_unstructured_ingest/test-ingest-src.sh ``` we can see (due to CI and local instance producing different results) actual line by line diff
29 lines
944 B
Bash
Executable File
29 lines
944 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Description: Validate that the number of directories in the output directory is as expected.
|
|
#
|
|
# Arguments:
|
|
# - $1: The expected number of directories in the output directory.
|
|
# - $2: Name of the output folder. This is used to determine the structured output path.
|
|
|
|
set +e
|
|
|
|
EXPECTED_NUM_DIRS=$1
|
|
OUTPUT_FOLDER_NAME=$2
|
|
SCRIPT_DIR=$(dirname "$(realpath "$0")")
|
|
OUTPUT_ROOT=${OUTPUT_ROOT:-$SCRIPT_DIR}
|
|
OUTPUT_DIR=$OUTPUT_ROOT/structured-output/$OUTPUT_FOLDER_NAME
|
|
|
|
|
|
NUMBER_OF_FOUND_DIRS="$(find "$OUTPUT_DIR" -type d -exec printf '.' \; | wc -c | xargs)"
|
|
|
|
# Note: single brackets and "-ne" operator were necessary for evaluation in CI
|
|
if [ "$NUMBER_OF_FOUND_DIRS" -ne "$EXPECTED_NUM_DIRS" ]; then
|
|
echo
|
|
echo "$EXPECTED_NUM_DIRS directories were expected to be found."
|
|
echo "$NUMBER_OF_FOUND_DIRS directories were found instead."
|
|
echo "Name of the directories found:"
|
|
find "$OUTPUT_DIR" -type d
|
|
exit 1
|
|
fi
|