This commit is contained in:
parent
0a6efbded9
commit
bc0d0ea889
@ -71,15 +71,20 @@ fi
|
|||||||
echo -e "\nTest 2: First run with directory argument"
|
echo -e "\nTest 2: First run with directory argument"
|
||||||
# Use a directory that should exist in most environments
|
# Use a directory that should exist in most environments
|
||||||
TEST_DIR="/tmp"
|
TEST_DIR="/tmp"
|
||||||
|
echo " Testing with directory: $TEST_DIR"
|
||||||
if [ -d "$TEST_DIR" ]; then
|
if [ -d "$TEST_DIR" ]; then
|
||||||
"$WHATSDIRTY_SCRIPT" "$TEST_DIR" > /dev/null 2>&1
|
echo " Directory exists, running script..."
|
||||||
if [ -f "$CONFIG_FILE" ] && [ "$(cat "$CONFIG_FILE")" = "$TEST_DIR" ]; then
|
SCRIPT_OUTPUT=$("$WHATSDIRTY_SCRIPT" "$TEST_DIR" 2>&1)
|
||||||
|
SCRIPT_EXIT_CODE=$?
|
||||||
|
echo " Script exit code: $SCRIPT_EXIT_CODE"
|
||||||
|
if [ $SCRIPT_EXIT_CODE -eq 0 ] && [ -f "$CONFIG_FILE" ] && [ "$(cat "$CONFIG_FILE")" = "$TEST_DIR" ]; then
|
||||||
print_test "Directory saved to config" "PASS"
|
print_test "Directory saved to config" "PASS"
|
||||||
else
|
else
|
||||||
print_test "Directory saved to config" "FAIL"
|
print_test "Directory saved to config" "FAIL"
|
||||||
echo " Expected config to contain: $TEST_DIR"
|
echo " Expected config to contain: $TEST_DIR"
|
||||||
echo " Config file exists: $([ -f "$CONFIG_FILE" ] && echo "yes" || echo "no")"
|
echo " Config file exists: $([ -f "$CONFIG_FILE" ] && echo "yes" || echo "no")"
|
||||||
[ -f "$CONFIG_FILE" ] && echo " Config contains: $(cat "$CONFIG_FILE")"
|
[ -f "$CONFIG_FILE" ] && echo " Config contains: $(cat "$CONFIG_FILE")"
|
||||||
|
echo " Script output: $SCRIPT_OUTPUT"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
print_test "Directory saved to config" "SKIP (test directory not found)"
|
print_test "Directory saved to config" "SKIP (test directory not found)"
|
||||||
|
@ -62,8 +62,8 @@ get_last_commit_hours() {
|
|||||||
local current_timestamp=$(date +%s)
|
local current_timestamp=$(date +%s)
|
||||||
local diff_seconds=$((current_timestamp - last_commit_timestamp))
|
local diff_seconds=$((current_timestamp - last_commit_timestamp))
|
||||||
|
|
||||||
# Convert to hours with decimal precision
|
# Convert to hours with decimal precision using awk (more portable than bc)
|
||||||
local hours_ago=$(echo "scale=1; $diff_seconds / 3600" | bc)
|
local hours_ago=$(awk "BEGIN {printf \"%.1f\", $diff_seconds / 3600}")
|
||||||
|
|
||||||
# Ensure leading zero for values less than 1
|
# Ensure leading zero for values less than 1
|
||||||
if [[ $hours_ago =~ ^\. ]]; then
|
if [[ $hours_ago =~ ^\. ]]; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user