Skip to content

Commit

Permalink
parapluu#308 Add test for short names
Browse files Browse the repository at this point in the history
  • Loading branch information
aronisstav committed Mar 28, 2020
1 parent 3632103 commit 97b079c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
5 changes: 3 additions & 2 deletions resources/bash_completion/concuerror
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ _concuerror()
--print_depth --pz --quiet --scheduling --scheduling_bound --scheduling_bound_type
--show_races --strict_scheduling --symbolic_names --test --timeout --treat_as_normal
--use_receive_patterns --verbosity --version"

opts="-a -d -x -f -g -h -i -k -m -o -q -b -c -s -t -v"

# Keep this sorted alphabetically
opts="-a -b -c -d -f -g -h -i -k -m -o -q -s -t -v -x"
local cur prev
if type _get_comp_words_by_ref &>/dev/null ; then
_get_comp_words_by_ref cur prev
Expand Down
3 changes: 3 additions & 0 deletions tests-real/suites/options/autocomplete-tests
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ print_blue "$0"
testing "Long options in sync with bash completion"
autocomplete_test autocomplete_long

testing "Short options in sync with bash completion"
autocomplete_test autocomplete_short

. footer
33 changes: 33 additions & 0 deletions tests-real/suites/options/autocomplete/autocomplete_short.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
-module(autocomplete_short).

-export([test/0]).

-include_lib("stdlib/include/assert.hrl").

test() ->
try
main()
catch
C:R ->
io:format(standard_error, "Class: ~p~nReason: ~p~n", [C, R]),
halt(1)
end.

main() ->
AutoOutput = os:cmd("./autocomplete_short.sh"),
AutoTokens = string:tokens(AutoOutput, " \n"),
Auto = usort(AutoTokens),

OptionSpec = concuerror_options:getopt_spec_no_default(),
OptsRaw = ["-" ++ [Short] || {_, Short, _, _, _} <- OptionSpec, Short =/= undefined],
Opts = usort(lists:sort(OptsRaw)),

io:format(standard_error, "Auto - Opts : ~p~n", [Auto -- Opts]),
io:format(standard_error, "Opts - Auto : ~p~n", [Opts -- Auto]),

?assertEqual(Opts, Auto).

usort(List) ->
USort = lists:usort(List),
?assertEqual(USort, List),
USort.
11 changes: 11 additions & 0 deletions tests-real/suites/options/autocomplete/autocomplete_short.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# load bash-completion functions
source $(dirname $0)/../../../../resources/bash_completion/concuerror

COMP_WORDS=(concuerror -)
COMP_CWORD=1

_concuerror ignored - concuerror

echo ${COMPREPLY[@]}

0 comments on commit 97b079c

Please sign in to comment.