Skip to content

Commit

Permalink
Tmain: add a case for testing broken --_paramdef-<LANG> option
Browse files Browse the repository at this point in the history
Signed-off-by: Masatake YAMATO <[email protected]>
  • Loading branch information
masatake committed Aug 30, 2024
1 parent e08dfaf commit 1429090
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 2 deletions.
75 changes: 75 additions & 0 deletions Tmain/broken-paramdef.d/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Copyright: 2018 Masatake YAMATO
# License: GPL-2

CTAGS="$1 --quiet --options=NONE"

title()
{
echo
echo "$@"

{
echo
echo "$@"
} 1>&2
}

{
title '# echo unknown lang'
${CTAGS} --_paramdef-NOSUCHLANG
${CTAGS} --_paramdef-NOSUCHLANG=param,desc

title '# no option value'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=

title '# wrong char in a field name'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=:
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=:abc
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=:abc,
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=:abc,description

title '# empty parameter name'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=,
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=,abc
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=,abc,
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=,abc,description

title '# empty description'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=abc
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=abc,

title '# no input file'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY=abc,desc

title '# inject a flag separator'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY='param,desc{foo}' --list-params=IMAGINARY

title '# inject a broken flag separator(1)'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY='param,desc{foo' --list-params=IMAGINARY

title '# inject a broken flag separator(2)'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY='param,desc{' --list-params=IMAGINARY

title '# use a { in description (1)'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY='param,desc\{' --list-params=IMAGINARY

title '# use a { in description (2)'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY='param,desc\{}' --list-params=IMAGINARY

title '# use a \ in description'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY='param,desc\\backslash' --list-params=IMAGINARY

title '# description started from {'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY='param,{' --list-params=IMAGINARY

title '# description started from \{'
${CTAGS} --langdef=IMAGINARY --_paramdef-IMAGINARY='param,\{' --list-params=IMAGINARY

} > /tmp/ctags-tmain-$$.stdout 2>/tmp/ctags-tmain-$$.stderr

sed -e 's/\.exe//g' < /tmp/ctags-tmain-$$.stdout
rm /tmp/ctags-tmain-$$.stdout

sed -e 's/\.exe//g' < /tmp/ctags-tmain-$$.stderr 1>&2
rm /tmp/ctags-tmain-$$.stderr
46 changes: 46 additions & 0 deletions Tmain/broken-paramdef.d/stderr-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

# echo unknown lang
ctags: Unknown language "NOSUCHLANG" in "_paramdef-NOSUCHLANG" option
ctags: Unknown language "NOSUCHLANG" in "_paramdef-NOSUCHLANG" option

# no option value
ctags: no parameter definition specified in "--_paramdef-IMAGINARY" option
ctags: no parameter definition specified in "--_paramdef-IMAGINARY" option

# wrong char in a field name
ctags: no parameter description specified in "--_paramdef-IMAGINARY" option
ctags: no parameter description specified in "--_paramdef-IMAGINARY" option
ctags: unacceptable char as part of parameter name in "--_paramdef-IMAGINARY" option: ':'
ctags: unacceptable char as part of parameter name in "--_paramdef-IMAGINARY" option: ':'

# empty parameter name
ctags: the parameter name in "--_paramdef-IMAGINARY" option is empty
ctags: the parameter name in "--_paramdef-IMAGINARY" option is empty
ctags: the parameter name in "--_paramdef-IMAGINARY" option is empty
ctags: the parameter name in "--_paramdef-IMAGINARY" option is empty

# empty description
ctags: no parameter description specified in "--_paramdef-IMAGINARY" option
ctags: parameter description in "--_paramdef-IMAGINARY" option is empty

# no input file
ctags: No files specified. Try "ctags --help".

# inject a flag separator

# inject a broken flag separator(1)
ctags: Warning: long flags specifier opened with `{' is not closed `}': "{foo"

# inject a broken flag separator(2)
ctags: Warning: long flags specifier opened with `{' is not closed `}': "{"

# use a { in description (1)

# use a { in description (2)

# use a \ in description

# description started from {
ctags: parameter description in "--_paramdef-IMAGINARY" option is empty

# description started from \{
42 changes: 42 additions & 0 deletions Tmain/broken-paramdef.d/stdout-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

# echo unknown lang

# no option value

# wrong char in a field name

# empty parameter name

# empty description

# no input file

# inject a flag separator
#NAME DESCRIPTION
param desc

# inject a broken flag separator(1)
#NAME DESCRIPTION
param desc

# inject a broken flag separator(2)
#NAME DESCRIPTION
param desc

# use a { in description (1)
#NAME DESCRIPTION
param desc{

# use a { in description (2)
#NAME DESCRIPTION
param desc{}

# use a \ in description
#NAME DESCRIPTION
param desc\backslash

# description started from {

# description started from \{
#NAME DESCRIPTION
param {
2 changes: 0 additions & 2 deletions main/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -3567,10 +3567,8 @@ static bool processLangDefineParam (const langType language,
pdef->name = eStrndup (parameter, name_end - parameter);
pdef->desc = desc;

#if 0
if (flags)
flagsEval (flags, NULL, 0, pdef);
#endif

parser = LanguageTable + language;
defineParam (parser->paramControlBlock, pdef, freePdef);
Expand Down

0 comments on commit 1429090

Please sign in to comment.