From a88564a061766026b7b80c85176ae7a30eb0d9be Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 22 Jan 2018 15:46:01 +0100 Subject: tests: merge sep1752 cal(1) tests * merge tests * use subtests for cal(1) calls Signed-off-by: Karel Zak --- tests/ts/cal/sep1752 | 109 ++++++++++++++++++++++---------------------------- tests/ts/cal/sep1752w | 81 ------------------------------------- 2 files changed, 47 insertions(+), 143 deletions(-) delete mode 100755 tests/ts/cal/sep1752w (limited to 'tests/ts/cal') diff --git a/tests/ts/cal/sep1752 b/tests/ts/cal/sep1752 index 8db7e3cac..986f01a60 100755 --- a/tests/ts/cal/sep1752 +++ b/tests/ts/cal/sep1752 @@ -26,73 +26,58 @@ USETERM=$( ts_has_option "useterm" "$*" ) MYMONTH="09 1752" MYYEAR="1752" -[ "$USETERM" == "yes" ] && TS_VERBOSE="yes" -ts_log "" +function call_cal_simple { + ts_log "$1" + shift + if [ "$USETERM" == "yes" ]; then + $TS_CMD_CAL "$@" + fi + $TS_CMD_CAL "$@" >> $TS_OUTPUT +} +function call_cal { + local testname=$(echo "$2" | sed 's/-//g') -ts_log "Gregorian - Monday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1m -fi -$TS_CMD_CAL -1m $MYMONTH >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1s $MYMONTH -fi -$TS_CMD_CAL -1s $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Monday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mj $MYMONTH -fi -$TS_CMD_CAL -1mj $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Sunday-based month" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sj $MYMONTH -fi -$TS_CMD_CAL -1sj $MYMONTH >> $TS_OUTPUT + if [ "$3" == "$MYYEAR" ]; then + testname="${testname}-year" + else + testname="${testname}-month" + fi + ts_init_subtest "$testname" + call_cal_simple "$@" + ts_finalize_subtest +} -ts_log "Gregorian - Monday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3m -fi -$TS_CMD_CAL -3m $MYMONTH >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3s $MYMONTH -fi -$TS_CMD_CAL -3s $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Monday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3mj $MYMONTH -fi -$TS_CMD_CAL -3mj $MYMONTH >> $TS_OUTPUT -ts_log "Julian - Sunday-based three months" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -3sj $MYMONTH -fi -$TS_CMD_CAL -3sj $MYMONTH >> $TS_OUTPUT +call_cal "Gregorian - Monday-based month with week numbers" -1mw $MYMONTH +call_cal "Gregorian - Sunday-based month with week numbers" -1sw $MYMONTH +call_cal "Julian - Monday-based month with week numbers" -1mjw $MYMONTH +call_cal "Julian - Sunday-based month with week numbers" -1sjw $MYMONTH +call_cal "Gregorian - Monday-based three months with week numbers" -3mw $MYMONTH +call_cal "Gregorian - Sunday-based three months with week numbers" -3sw $MYMONTH +call_cal "Julian - Monday-based three months with week numbers" -3mjw $MYMONTH +call_cal "Julian - Sunday-based three months with week numbers" -3sjw $MYMONTH +call_cal "Gregorian - Monday-based year with week numbers" -1mw $MYYEAR +call_cal "Gregorian - Sunday-based year with week numbers" -1sw $MYYEAR +call_cal "Julian - Monday-based year with week numbers" -1mjw $MYYEAR +call_cal "Julian - Sunday-based year with week numbers" -1sjw $MYYEAR -ts_log "Gregorian - Monday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1m $MYYEAR -fi -$TS_CMD_CAL -1m $MYYEAR >> $TS_OUTPUT -ts_log "Gregorian - Sunday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1s $MYYEAR -fi -$TS_CMD_CAL -1s $MYYEAR >> $TS_OUTPUT -ts_log "Julian - Monday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1mj $MYYEAR -fi -$TS_CMD_CAL -1mj $MYYEAR >> $TS_OUTPUT -ts_log "Julian - Sunday-based year" -if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL -1sj $MYYEAR -fi -$TS_CMD_CAL -1sj $MYYEAR >> $TS_OUTPUT +ts_init_subtest "week-iso" +call_cal_simple "Gregorian - address by week number" --week=40 --iso $MYYEAR +ts_finalize_subtest + +call_cal "Gregorian - Monday-based month" -1m $MYMONTH +call_cal "Gregorian - Sunday-based month" -1s $MYMONTH +call_cal "Julian - Monday-based month" -1mj $MYMONTH +call_cal "Julian - Sunday-based month" -1sj $MYMONTH +call_cal "Gregorian - Monday-based three months" -3m $MYMONTH +call_cal "Gregorian - Sunday-based three months" -3s $MYMONTH +call_cal "Julian - Monday-based three months" -3mj $MYMONTH +call_cal "Julian - Sunday-based three months" -3sj $MYMONTH +call_cal "Gregorian - Monday-based year" -1m $MYYEAR +call_cal "Gregorian - Sunday-based year" -1s $MYYEAR +call_cal "Julian - Monday-based year" -1mj $MYYEAR +call_cal "Julian - Sunday-based year" -1sj $MYYEAR ts_finalize diff --git a/tests/ts/cal/sep1752w b/tests/ts/cal/sep1752w deleted file mode 100755 index a3e15550d..000000000 --- a/tests/ts/cal/sep1752w +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash - -# This file is part of util-linux. -# -# This file is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This file is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -TS_TOPDIR="${0%/*}/../.." -TS_DESC="September 1752 with week numbers" - -. $TS_TOPDIR/functions.sh -ts_init "$*" - -ts_check_test_command "$TS_CMD_CAL" - -export TERM=linux - -USETERM=$( ts_has_option "useterm" "$*" ) -MYMONTH="09 1752" -MYYEAR="1752" - -function call_cal_simple { - ts_log "$1" - shift - if [ "$USETERM" == "yes" ]; then - $TS_CMD_CAL "$@" - fi - $TS_CMD_CAL "$@" >> $TS_OUTPUT -} - -function call_cal { - local testname=$(echo "$2" | sed 's/-//g') - - if [ "$3" == "$MYYEAR" ]; then - testname="${testname}-year" - else - testname="${testname}-month" - fi - - ts_init_subtest "$testname" - call_cal_simple "$@" - ts_finalize_subtest -} - - -call_cal "Gregorian - Monday-based month with week numbers" -1mw $MYMONTH - -call_cal "Gregorian - Sunday-based month with week numbers" -1sw $MYMONTH - -call_cal "Julian - Monday-based month with week numbers" -1mjw $MYMONTH - -call_cal "Julian - Sunday-based month with week numbers" -1sjw $MYMONTH - -call_cal "Gregorian - Monday-based three months with week numbers" -3mw $MYMONTH - -call_cal "Gregorian - Sunday-based three months with week numbers" -3sw $MYMONTH - -call_cal "Julian - Monday-based three months with week numbers" -3mjw $MYMONTH - -call_cal "Julian - Sunday-based three months with week numbers" -3sjw $MYMONTH - -call_cal "Gregorian - Monday-based year with week numbers" -1mw $MYYEAR - -call_cal "Gregorian - Sunday-based year with week numbers" -1sw $MYYEAR - -call_cal "Julian - Monday-based year with week numbers" -1mjw $MYYEAR - -call_cal "Julian - Sunday-based year with week numbers" -1sjw $MYYEAR - -ts_init_subtest "week-iso" -call_cal_simple "Gregorian - address by week number" --week=40 --iso $MYYEAR -ts_finalize_subtest - -ts_finalize -- cgit v1.2.3-55-g7522