Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

weird behaviour for piped commands #19

Closed
pkeroulas opened this issue May 25, 2017 · 1 comment
Closed

weird behaviour for piped commands #19

pkeroulas opened this issue May 25, 2017 · 1 comment

Comments

@pkeroulas
Copy link
Contributor

Intuitively, I wanted to check if cukinia supports piped commands.

This sequence

as grep cukinia_cmd echo toto | grep toto
as cat  cukinia_cmd echo toto | cat 
as awk  cukinia_cmd echo toto | awk '/toto/'
as wc   cukinia_cmd echo toto | wc
as sed  cukinia_cmd echo toto | sed 's/o/i/g'
cukinia_log "$cukinia_tests"

gives:

[PASS] cat
        1         2        21
[PASS] sed
0

It looks like something, probablyecho toto, is executed because of PASS but the result is ignored (cukinia_test==0). So, the output is confusing because cat and sed look fine. And it's not clear why some commands ouput something while other don't.

Quoting the expression ("cmd1|cmd2") helps cukinia_test incrementing but always returns FAIL regardless of cmd1 and cmd2.

The use of "|" in the syntax should be either forbidden by documentation either fixed somehow.

@joufella
Copy link
Member

The cukinia config file is just a shell script, so when you do:

as "my test" cukinia_cmd echo toto | grep toto

The following happens:

  • as "my test" cukinia_cmd echo toto is executed
  • this command produces the output [PASS] my test
  • this output is piped into grep toto
  • toto is not present on the line, so nothing is displayed.

The 1 2 21 output is normal piping the same type of string into wc.

For more complex tests like that, you should use

# complex test scenario
cat /myfile | sed -e 'some magic' | grep -q 'some result'
as "this complex scenario" cukinia_test $? -eq 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants