From b62207db4d24609624e1369978acead48b137e75 Mon Sep 17 00:00:00 2001 From: "xiongdian.me" Date: Tue, 6 Dec 2022 16:37:34 +0800 Subject: [PATCH] ci: test common.sh getopts --- tools/test-getopts.sh | 14 ++++++++++++++ tools/test.zsh | 1 + 2 files changed, 15 insertions(+) create mode 100755 tools/test-getopts.sh diff --git a/tools/test-getopts.sh b/tools/test-getopts.sh new file mode 100755 index 0000000..430910d --- /dev/null +++ b/tools/test-getopts.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -ex +OPTS="-a -bcl --color --arg1=1 --arg2 2 yes" +TARGET_OPTS="-a -b -c --arg1 1 --arg2 2 yes" +set -- $OPTS + +THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]:-${(%):-%x}}" )" && pwd ) +source "$THIS_DIR/common.sh" + +test "${GOT_OPTS[*]}" = "$TARGET_OPTS" +test "$*" = "$OPTS" +test "$DFS_LITE" = "1" +is_tty +test -z "$DFS_QUIET" \ No newline at end of file diff --git a/tools/test.zsh b/tools/test.zsh index c1eaa05..44e18e4 100644 --- a/tools/test.zsh +++ b/tools/test.zsh @@ -23,6 +23,7 @@ test ~ -ef "$(pwd)" dogo doll dfs cd +./tools/test-getopts.sh tools/common.sh get_os_type tools/common.sh get_linux_dist