Skip to content

Commit

Permalink
Fix —assert-* checks (binpash#742)
Browse files Browse the repository at this point in the history
* Fix: inform_daemon_exit on assertion exit

Otherwise, --assert_compiler_success hangs.
--assert_all_regions_parallelizable doesn't fail,
but I also copied the change there.
The tests using the flag pass.

Signed-off-by: Bolun Thompson <[email protected]>

* Fix: correctly parse "is parallelizable" output

Signed-off-by: Bolun Thompson <[email protected]>

---------

Signed-off-by: Bolun Thompson <[email protected]>
  • Loading branch information
BolunThompson authored and kwakubiney committed Jan 28, 2025
1 parent 023e0cc commit 669b57b
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions compiler/orchestrator_runtime/pash_prepare_call_compiler.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## OUTPUT: When it completes it sets "$pash_script_to_execute"

## Let daemon know that this region is done
function inform_daemon_exit () {
## Send to daemon
msg="Exit:${process_id}"
daemon_response=$(pash_communicate_daemon_just_send "$msg")
}

## Only needed for expansion
export pash_input_args=( "$@" )

Expand Down Expand Up @@ -33,7 +40,8 @@ pash_redir_output echo "$$: (2) Before asking the daemon for compilation..."
msg="Compile:${pash_compiled_script_file}| Variable File:${pash_runtime_shell_variables_file}| Input IR File:${pash_input_ir_file}"
daemon_response=$(pash_communicate_daemon "$msg") # Blocking step, daemon will not send response until it's safe to continue

if [[ "$daemon_response" == *"not all regions are parallelizable"* ]]; then
# WARNING: finicky!
if [[ "$daemon_response" == *"not"*"parallelizable"* ]]; then
pash_all_region_parallelizable=1
else
pash_all_region_parallelizable=0
Expand Down Expand Up @@ -66,17 +74,20 @@ pash_redir_output echo "$$: (2) Compiler exited with code: $pash_runtime_return_
## only when --assert_all_regions_parallellizable is used do we care about all regions being parallelizable
if [ "$pash_all_region_parallelizable" -ne 0 ] && [ "$pash_assert_all_regions_parallelizable_flag" -eq 1 ]; then
pash_redir_output echo "$$: ERROR: (2) Compiler failed with error code because some regions were not parallelizable: $pash_all_region_parallelizable while assert_all_regions_parallelizable_flag was enabled! Exiting PaSh..."
inform_daemon_exit
exit 1
fi

if [ "$pash_runtime_return_code" -ne 0 ] && [ "$pash_assert_all_regions_parallelizable_flag" -eq 1 ]; then
pash_redir_output echo "$$: ERROR: (2) Compiler failed with error code: $pash_runtime_return_code while assert_all_regions_parallelizable_flag was enabled! Exiting PaSh..."
inform_daemon_exit
exit 1
fi

## for pash_assert_compiler_success_flag, exit when return code is 0 (general exception caught) and not when all regions are parallelizable
## for pash_assert_compiler_success_flag, exit when return code is not 0 (general exception caught) and when all regions are parallelizable
if [ "$pash_runtime_return_code" -ne 0 ] && [ "$pash_all_region_parallelizable" -eq 0 ] && [ "$pash_assert_compiler_success_flag" -eq 1 ]; then
pash_redir_output echo "$$: ERROR: (2) Compiler failed with error code: $pash_runtime_return_code while assert_compiler_success was enabled! Exiting PaSh..."
inform_daemon_exit
exit 1
fi

Expand All @@ -93,11 +104,3 @@ if [ "$pash_runtime_return_code" -ne 0 ] || [ "$pash_dry_run_compiler_flag" -eq
else
export pash_script_to_execute="${pash_compiled_script_file}"
fi

## Let daemon know that this region is done
function inform_daemon_exit () {
## Send to daemon
msg="Exit:${process_id}"
daemon_response=$(pash_communicate_daemon_just_send "$msg")
}

0 comments on commit 669b57b

Please sign in to comment.