Return component ONCE slots with handler resolution

This commit is contained in:
udo
2026-07-18 11:47:28 +00:00
parent 0e0c0b6ccc
commit 418c5812dc
4 changed files with 93 additions and 36 deletions
+1
View File
@@ -69,6 +69,7 @@ if [[ "$action" == "run" ]]; then
scripts/test_dependency_invalidation.sh
scripts/test_cold_component_deadline.sh
scripts/test_nested_component_props.sh
scripts/test_component_once_prefetch.sh
scripts/test_relative_component_cache.sh
scripts/test_password_hashing.sh
scripts/test_mysql_epoch_refresh.sh
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
test_name="component-once-prefetch-test-$$"
site_directory="${UCE_TEST_SITE_DIRECTORY:-site}"
if [[ -z "${UCE_TEST_SITE_DIRECTORY:-}" && -r /etc/uce/settings.cfg ]]; then
configured_site_directory=$(awk -F= '/^[[:space:]]*SITE_DIRECTORY[[:space:]]*=/ {gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2); print $2; exit}' /etc/uce/settings.cfg)
if [[ -n "${configured_site_directory:-}" ]]; then
site_directory="$configured_site_directory"
fi
fi
source_dir="$site_directory/$test_name"
cleanup() {
rm -rf "$source_dir"
}
trap cleanup EXIT
mkdir -p "$source_dir"
printf '%s\n' \
'CLI(Request& context) {' \
' String first = component("child", context);' \
' String second = component("child", context);' \
' DValue perf = request_perf();' \
' print(first, ",", second, ",", perf["component_resolve_count"].to_u64(), ",", perf["component_loaded_reuse_count"].to_u64());' \
'}' >"$source_dir/entry.uce"
printf '%s\n' \
'ONCE(Request& context) { context.call["once"] = context.call["once"].to_u64() + 1; }' \
'COMPONENT(Request& context) { print(context.call["once"].to_u64()); }' >"$source_dir/child.uce"
output=$(scripts/uce-cli "/$test_name/entry.uce")
if [[ "$output" != "1,1,1,0" ]]; then
echo "component ONCE slot was not returned with the primary handler: $output" >&2
exit 1
fi
echo "component ONCE prefetch passed"