From 63e8b2a7eb56f77d0cf19079e01c2c481f1501cc Mon Sep 17 00:00:00 2001 From: Lifailon Date: Wed, 26 Feb 2025 13:21:52 +0300 Subject: [PATCH] update opt for interface testing --- .github/workflows/build.yml | 15 +++++---------- test.sh | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d815809..2dd0128 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,18 +29,13 @@ on: default: true type: boolean testFunctions: - description: 'Testing functions and performance' + description: 'Go test function' default: true type: boolean testInterface: - description: 'Testing interface' + description: 'Interface testing in TMUX' default: true type: boolean - Timeout: - description: 'Timeout for interface testing' - required: true - default: 5 - type: number jobs: build: @@ -97,14 +92,14 @@ jobs: if: ${{ github.event.inputs.testInterface == 'true' && github.event.inputs.Distro == 'macos-15' }} run: brew install tmux - - name: Interface testing + - name: Interface testing in TMUX if: ${{ github.event.inputs.testInterface == 'true' }} run: | tmux -V chmod +x test.sh - bash test.sh ${{ github.event.inputs.Timeout }} true + bash test.sh 5 true - - name: Go test functions + - name: Go test function if: ${{ github.event.inputs.testFunctions == 'true' }} run: | sudo go test -v diff --git a/test.sh b/test.sh index e8461a2..5d8efb7 100644 --- a/test.sh +++ b/test.sh @@ -3,7 +3,7 @@ # bash test.sh # bash test.sh 3 true -timeout=${1:-5} +timeout=${1:-5} # default timeout 5 seconds debug=$2 exitCode=0 @@ -35,7 +35,7 @@ if [ "$journalctlVersion" == "false" ]; then else tmux send-keys -t test-session "cron" tmux send-keys -t test-session "$(echo -e '\t')" - tmux send-keys -t test-session "$(echo -e '\x1b[C')" + tmux send-keys -t test-session "$(echo -e '\x1b[C')" start_time=$(date +%s) while true; do @@ -77,6 +77,17 @@ tmux send-keys -t test-session "input" tmux send-keys -t test-session "$(echo -e '\t\t')" tmux send-keys -t test-session "$(echo -e '\x1b[C')" +start_time=$(date +%s) +while true; do + current_time=$(date +%s) + elapsed=$((current_time - start_time)) + if [[ $(tmux capture-pane -p | grep -q "< Optional p") && $(tmux capture-pane -p | grep -q -v "Searching") ]] || [ "$elapsed" -ge "$timeout" ]; then + break + fi +done + +tmux send-keys -t test-session "$(echo -e '\x1b[C')" + start_time=$(date +%s) while true; do current_time=$(date +%s)