#! /bin/bash
# @file        timeout-simple-comments.bash
#              Test to ensure that per-test-timeout for simple tests work as expected. Tests both inline and multiline styled timeout comments.
# @author      Eli Deluzio, elijah@distributive.network
# @author      Wes Garland, wes@distributive.network
# @date        Oct 2023

# peter-timeout: 20
# There is 3 simple tests in this file, each with a 3 second timeout, so use a larger timeout in this file to account for that

source $(dirname "$0")/helper-functions.incl

# Both tests have comment timeouts of 3s, delays of 10s, and are fired off with manual timeouts of 1s.
# We expect the comment timeouts to override the 10s delay and the 1s manual timeout.
# Tests are expected to fail, and actual timeouts vs expected timeouts will always be off by a couple decimals,
# so ensure we're in the right ballpark (~3 seconds) to pass
pass 'inline timeout .simple.failing works'         if_match 'timed out after 3.'       peter -v --timeout 1    ./¬timeout-inline.simple
pass 'multiline timeout .simple.failing works'      if_match 'timed out after 3.'       peter -v --timeout 1    ./¬timeout-multiline-1.simple
pass 'multiline timeout .simple.failing works'      if_match 'timed out after 3.'       peter -v --timeout 1    ./¬timeout-multiline-2.simple

echo "Ran ${test} subtests; exitCode=${exitCode}"
exit $exitCode
