From 94d53f4fc8954469579be420f0921e73fd69b99b Mon Sep 17 00:00:00 2001 From: Dominic Ricottone Date: Fri, 16 Sep 2022 21:37:57 -0500 Subject: [PATCH] wttr update Added test suite. wttr incorrectly advertised support for -V as the short form of --version. --- core/test/wttr.bats | 39 +++++++++++++++++++++++++++++++++++++++ core/wttr | 4 ++-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 core/test/wttr.bats diff --git a/core/test/wttr.bats b/core/test/wttr.bats new file mode 100644 index 0000000..6e119df --- /dev/null +++ b/core/test/wttr.bats @@ -0,0 +1,39 @@ +#!/usr/bin/env bats +bats_require_minimum_version 1.5.0 + +@test "wttr version" { + run --separate-stderr wttr --version + [ "$status" -eq 0 ] + [ "$output" = "wttr 1.1" ] + [ "$stderr" = "" ] +} + +@test "wttr version short" { + run --separate-stderr wttr -v + [ "$status" -eq 0 ] + [ "$output" = "wttr 1.1" ] + [ "$stderr" = "" ] +} + +@test "wttr help" { + run --separate-stderr wttr --help + [ "$status" -eq 0 ] + [ "${lines[0]}" = "Wrapper around 'wego' to fix double-wide runes for some fonts" ] + [ "${lines[1]}" = "Usage: wttr" ] + [ "${lines[2]}" = "Options:" ] + [ "${lines[3]}" = " -h, --help print this message and exit" ] + [ "${lines[4]}" = " -v, --version print version number and exit" ] + [ "$stderr" = "" ] +} + +@test "wttr help short" { + run --separate-stderr wttr -h + [ "$status" -eq 0 ] + [ "${lines[0]}" = "Wrapper around 'wego' to fix double-wide runes for some fonts" ] + [ "${lines[1]}" = "Usage: wttr" ] + [ "${lines[2]}" = "Options:" ] + [ "${lines[3]}" = " -h, --help print this message and exit" ] + [ "${lines[4]}" = " -v, --version print version number and exit" ] + [ "$stderr" = "" ] +} + diff --git a/core/wttr b/core/wttr index e0ad569..3f61867 100755 --- a/core/wttr +++ b/core/wttr @@ -1,13 +1,13 @@ #!/bin/sh name="wttr" -version="1.0" +version="1.1" help_message=$(/usr/bin/cat <<-EOF Wrapper around 'wego' to fix double-wide runes for some fonts Usage: wttr Options: -h, --help print this message and exit - -V, --version print version number and exit + -v, --version print version number and exit EOF ) -- 2.45.2