update all the branch changes to the master

pull/3908/head
Jia Hu 2024-03-25 14:24:45 -04:00
parent 1a4dbb4bd7
commit 8681a23aa0
6 changed files with 182 additions and 32 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

View File

@ -25,7 +25,6 @@ jobs:
fi
# Add steps for other operating systems if needed, similar to the Linux steps above.
- name: Build tmux
run: |
sh autogen.sh
@ -36,20 +35,8 @@ jobs:
- name: Run Tests
working-directory: ./regress
run: |
chmod +x *.sh
sh *.sh
## chmod +x tty-keys.sh
## sh tty-keys.sh
## chmod +x format-strings.sh
## sh format-strings.sh
## chmod +x copy-mode-test-emacs.sh
## sh copy-mode-test-emacs.sh
## chmod +x copy-mode-test-vi.sh
## sh copy-mode-test-vi.sh
## chmod +x new-session-environment.sh
## sh new-session-environment.sh
for test_script in *.sh; do
chmod +x $test_script
echo Running test $test_script
./$test_script
done

View File

@ -19,7 +19,7 @@
#include <sys/types.h>
#include <stdlib.h>
/*small tests*/
#include "tmux.h"
static int alerts_fired;

View File

@ -25,14 +25,34 @@ $TMUX send-keys -X previous-word
$TMUX send-keys -X previous-space
$TMUX send-keys -X previous-word
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer 2>/dev/null)" = "" ] || exit 1
if [ "$($TMUX show-buffer 2>/dev/null)" = "" ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
# Test that `next-word-end` does not skip single-letter words.
$TMUX send-keys -X next-word-end
$TMUX send-keys -X begin-selection
$TMUX send-keys -X previous-word
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer)" = "A" ] || exit 1
if [ "$($TMUX show-buffer)" = "A" ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
# Test that `next-word-end` wraps around indented line breaks.
$TMUX send-keys -X next-word
@ -42,35 +62,85 @@ $TMUX send-keys -X begin-selection
$TMUX send-keys -X next-word-end
$TMUX send-keys -X next-word-end
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer)" = "$(echo -e "words\n Indented")" ] || exit 1
if [ "$($TMUX show-buffer)" != "$(printf "words\n Indented")" ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
# Test that `next-word` wraps around un-indented line breaks.
$TMUX send-keys -X next-word
$TMUX send-keys -X begin-selection
$TMUX send-keys -X next-word
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer)" = "$(echo -e "line\n")" ] || exit 1
if [ "$($TMUX show-buffer)" = "$(printf "line\n")" ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
# Test that `next-word-end` treats periods as letters.
$TMUX send-keys -X next-word
$TMUX send-keys -X begin-selection
$TMUX send-keys -X next-word-end
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer)" = "line..." ] || exit 1
if [ "$($TMUX show-buffer)" = "line..." ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
# Test that `previous-word` and `next-word` treat periods as letters.
$TMUX send-keys -X previous-word
$TMUX send-keys -X begin-selection
$TMUX send-keys -X next-word
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer)" = "$(echo -e "line...\n")" ] || exit 1
if [ "$($TMUX show-buffer)" = "$(printf "line...\n")" ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
# Test that `previous-space` and `next-space` treat periods as letters.
$TMUX send-keys -X previous-space
$TMUX send-keys -X begin-selection
$TMUX send-keys -X next-space
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer)" = "$(echo -e "line...\n")" ] || exit 1
if [ "$($TMUX show-buffer)" = "$(printf "line...\n")" ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
# Test that `next-word` and `next-word-end` treat other symbols as letters.
$TMUX send-keys -X begin-selection
@ -79,7 +149,17 @@ $TMUX send-keys -X next-word
$TMUX send-keys -X next-word-end
$TMUX send-keys -X next-word-end
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer)" = "... @nd then \$ym_bols[]{}" ] || exit 1
if [ "$($TMUX show-buffer)" = "... @nd then \$ym_bols[]{}" ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
# Test that `previous-word` treats other symbols as letters
# and `next-word` wraps around for indented symbols
@ -87,20 +167,50 @@ $TMUX send-keys -X previous-word
$TMUX send-keys -X begin-selection
$TMUX send-keys -X next-word
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer)" = "$(echo -e "\$ym_bols[]{}\n ")" ] || exit 1
if [ "$($TMUX show-buffer)" = "$(printf "\$ym_bols[]{}\n ")" ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
# Test that `next-word-end` treats digits as letters
$TMUX send-keys -X next-word-end
$TMUX send-keys -X begin-selection
$TMUX send-keys -X next-word-end
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer)" = " 500xyz" ] || exit 1
if [ "$($TMUX show-buffer)" = " 500xyz" ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
# Test that `previous-word` treats digits as letters
$TMUX send-keys -X begin-selection
$TMUX send-keys -X previous-word
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer)" = "500xyz" ] || exit 1
if [ "$($TMUX show-buffer)" = "500xyz" ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
# Test that `next-word` and `next-word-end` stop at the end of text.
$TMUX send-keys -X begin-selection
@ -110,7 +220,17 @@ $TMUX send-keys -X next-word
$TMUX send-keys -X next-space
$TMUX send-keys -X next-space-end
$TMUX send-keys -X copy-selection
[ "$($TMUX show-buffer)" = "500xyz" ] || exit 1
if [ "$($TMUX show-buffer)" = "500xyz" ]
then
actual=$($TMUX show-buffer)
expected=$(printf "words\n Indented")
echo "actual: "
echo $actual
echo "expected: "
echo $expected
exit 1
fi
$TMUX kill-server 2>/dev/null
exit 0

44
test_script.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/bash
cd regress
# Number of commits to check out and test, for demo purposes
NUM_COMMITS=2
sum=0
# Get the last N commits
COMMITS=$(git log --format="%H" -n $NUM_COMMITS)
# Variable to store the total number of tests run
TOTAL_TESTS=$(find . -type f -name "*.sh" | wc -l)
TOTAL_PASS_COMMIT=0
for COMMIT in $COMMITS; do
echo "start loop"
# Variable to store the number of passed tests
PASSED_TESTS=0
# Checkout the commit
git checkout $COMMIT
for TEST_SCRIPT in *.sh; do
echo running $TEST_SCRIPT
chmod +x $TEST_SCRIPT
# Execute the test script and check if it passes
if ./$TEST_SCRIPT; then
PASSED_TESTS=$((PASSED_TESTS + 1))
((sum+=1))
fi
done
# Calculate the pass rate
PASS_RATE=$(echo "scale=2; $PASSED_TESTS / $TOTAL_TESTS * 100" | bc)
echo "Pass rate: $PASS_RATE%"
if [ "$PASSED_TESTS" -eq "$TOTAL_TESTS" ]; then
((TOTAL_PASS_COMMIT+=1))
fi
done
# Calculate the Commit Success Rate
PASS_RATE=$((TOTAL_PASS_COMMIT / NUM_COMMITS))
echo "COMMIT SUCCESS RATE: $PASS_RATE%"
average=$(echo "scale=2; $sum / ($TOTAL_TESTS * $NUM_COMMITS) * 100" | bc)
echo "AVERAGE TEST SUCCESS RATE: $average%"

View File

@ -17,7 +17,6 @@
*/
#include <sys/types.h>
/*small and non-functional change*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>