Skip to content

Instantly share code, notes, and snippets.

@Pavel-Durov
Created February 1, 2025 17:54
Show Gist options
  • Save Pavel-Durov/6e41587eaa2a51298776bd64ec1f9bd1 to your computer and use it in GitHub Desktop.
Save Pavel-Durov/6e41587eaa2a51298776bd64ec1f9bd1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage: shrinkray --timeout 10 --parallelism 50 --no-clang-delta shrinkray_interest.sh ./cstack.minimal.lua
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <input.lua>"
exit 1
fi
INPUT="$1"
LUA_EXEC="$SCRIPT_DIR/../src/lua"
if [ ! -x "$LUA_EXEC" ]; then
echo "Error: Lua executable not found at '$LUA_EXEC'"
exit 1
fi
export LUA_PATH="$SCRIPT_DIR/libs/?.so;$SCRIPT_DIR/libs/?.lua;$SCRIPT_DIR/?.lua;;"
if [ ! -f "$INPUT" ]; then
echo "Error: Input file '$INPUT' does not exist."
exit 1
fi
# Create a unique temporary log file
LOG_FILE=./log.shrinkray.log
# Run the Lua script and capture output
RUST_BACKTRACE=full YKD_OPT=0 YKD_SERIALISE_COMPILATION=1 "$LUA_EXEC" -e "_U=true" "$INPUT" > "$LOG_FILE" 2>&1
# Define the error pattern to search for
ERROR_PATTERN="attempt to call a boolean value (field 'resume')"
if grep -q "$ERROR_PATTERN" "$LOG_FILE"; then
rm "$LOG_FILE"
exit 0
else
rm "$LOG_FILE"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment