Test-Perinci-CmdLine
view release on metacpan or search on metacpan
- Add test for cmdline_src=stdin_or_args (Rinci 1.1.79).
1.38 2016-02-04 Released-By: PERLANCAR
- Adjust to Perinci::Examples 0.69.
1.37 2016-01-22 Released-By: PERLANCAR
- Reorganize streaming tests and update to
Perinci::Examples::Stream 0.68 (renamed functions).
1.36 2016-01-22 Released-By: PERLANCAR
- [Bugfix] Adjust expected test result because of chomping of
streaming input records.
1.35 2016-01-22 Released-By: PERLANCAR
- [Bugfix] Add test to really check that stream input record
chomping is done.
1.34 2016-01-22 Released-By: PERLANCAR
- Add more tests for validation of streaming output and input.
1.33 2016-01-21 Released-By: PERLANCAR
- Add clause exit_code_like.
- [Incompatible change] Add/rename some tags.
1.32 2016-01-20 Released-By: PERLANCAR
- Fix/tweak streaming tests.
1.31 2015-12-02 Released-By: PERLANCAR
- Add new syntax of specifying configuration for subcommand
([SUBCMDNAME] -> [subcommand=SUBCMDNAME]).
1.30 2015-11-28 Released-By: PERLANCAR
1.26 2015-09-29 Released-By: PERLANCAR
- No functional changes.
- Tag dry-run tests.
1.25 2015-09-29 Released-By: PERLANCAR
- Add tests: some other common options, cmdline_src, streaming, tx,
result metadata, JSON-encoded argument.
- Refactor into run_test_groups().
- Export pericmd_ok() by default.
1.24 2015-09-28 Released-By: PERLANCAR
- Use App::GenPericmdScript to reduce code duplication.
lib/Test/Perinci/CmdLine.pm view on Meta::CPAN
tags => ['tx', 'dry-run'],
name => 'dry_run (using tx) (w/)',
gen_args => {url=>'/Perinci/Examples/Tx/check_state'},
argv => [qw/--dry-run/],
stdout_like => qr/check_state/,
},
],
}, # tx
{
name => 'streaming',
before_all_tests => sub {
write_text("$tempdir/infile-str", "one\ntwo three\nfour\n");
write_text("$tempdir/infile-hash-json", qq({}\n{"a":1}\n{"b":2,"c":3}\n{"d":4}\n));
write_text("$tempdir/infile-invalid-json", qq({}\n{\n));
write_text("$tempdir/infile-int", qq(1\n3\n5\n));
write_text("$tempdir/infile-invalid-int", qq(1\nx\n5\n));
write_text("$tempdir/infile-words", qq(word1\nword2\n));
write_text("$tempdir/infile-invalid-words", qq(word1\nword2\nnot a word\n));
},
tests => [
# streaming input
{
tags => ['streaming', 'streaming-input'],
name => "stream input, simple type, chomp on",
gen_args => {url => '/Perinci/Examples/Stream/count_lines'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => ["$tempdir/infile-str"],
stdout_like => qr/
3
/mx,
},
{
tags => ['streaming', 'streaming-input'],
name => "stream input, simple type, chomp off",
gen_args => {url => '/Perinci/Examples/Stream/wc'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => ["$tempdir/infile-str"],
stdout_like => qr/
^chars \s+ 19\n
^lines \s+ 3\n
^words \s+ 4\n
/mx,
},
{
tags => ['streaming', 'streaming-input'],
name => "stream input, json stream",
gen_args => {url => '/Perinci/Examples/Stream/wc_keys'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => ["$tempdir/infile-hash-json"],
stdout_like => qr/^keys \s+ 4\n/mx,
},
{
tags => ['streaming', 'streaming-input', 'validate-streaming-input'],
name => 'stream input, simple type, word validation', # also test that each record is chomp-ed
gen_args => {url => '/Perinci/Examples/Stream/count_words'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => ["$tempdir/infile-words"],
stdout_like => qr/2/,
},
{
tags => ['streaming', 'streaming-input', 'validate-streaming-input'],
name => 'stream input, simple types, word validation, error',
gen_args => {url => '/Perinci/Examples/Stream/count_words'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => ["$tempdir/infile-invalid-words"],
exit_code_like => qr/[1-9]/,
stderr_like => qr/fails validation/,
},
{
tags => ['streaming', 'streaming-input', 'validate-streaming-input'],
name => 'stream input, simple types, word validation, error',
gen_args => {url => '/Perinci/Examples/Stream/count_words'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => ["$tempdir/infile-invalid-words"],
exit_code_like => qr/[1-9]/,
stderr_like => qr/fails validation/,
},
{
tags => ['streaming', 'streaming-input', 'validate-streaming-input'],
name => 'stream input, json stream, error',
gen_args => {url => '/Perinci/Examples/Stream/wc_keys'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => ["$tempdir/infile-invalid-json"],
exit_code => 200,
},
# streaming result
{
tags => ['streaming', 'streaming-result', 'validate-streaming-result'],
name => "stream result, simple types, word validation",
gen_args => {url => '/Perinci/Examples/Stream/produce_words_err'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => ["-n", 9],
},
{
tags => ['streaming', 'streaming-result', 'validate-streaming-result'],
name => "stream result, simple types, word validation, error",
gen_args => {url => '/Perinci/Examples/Stream/produce_words_err'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => ["-n", 10],
exit_code_like => qr/[1-9]/,
stderr_like => qr/fails validation/,
},
{
tags => ['streaming', 'streaming-result'],
name => "stream result, json stream",
gen_args => {url => '/Perinci/Examples/Stream/produce_hashes'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => [qw/-n 3/],
stdout_like => qr/
^\Q{"num":1}\E\n
^\Q{"num":2}\E\n
^\Q{"num":3}\E\n
/mx,
},
# streaming input+result
{
tags => ['streaming', 'streaming-input', 'streaming-result'],
name => "stream input+result, simple type, float validation",
gen_args => {url => '/Perinci/Examples/Stream/square_nums'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => ["$tempdir/infile-int"],
stdout_like => qr/
^"?1"?\n
^"?9"?\n
^"?25"?\n
/mx,
},
{
tags => ['streaming', 'streaming-input', 'streaming-result', 'validate-streaming-input'],
name => "stream input+result, simple type, float validation, error",
gen_args => {url => '/Perinci/Examples/Stream/square_nums'},
inline_gen_args => {load_module=>["Perinci::Examples::Stream"]},
argv => ["$tempdir/infile-invalid-int"],
exit_code_like => qr/[1-9]/, # sometimes it's 9, sometimes it's 25; looks like the input line is being used somehow as exit code?
stderr_like => qr/fails validation/,
},
],
}, # streaming
{
name => 'result metadata',
tests => [
{
name => 'cmdline.exit_code',
gen_args => {url=>'/Perinci/Examples/CmdLineResMeta/exit_code'},
inline_gen_args => {load_module=>['Perinci::Examples::CmdLineResMeta']},
argv => [qw//],
exit_code => 7,
( run in 0.257 second using v1.01-cache-2.11-cpan-4d50c553e7e )