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

Parameters:dynamic from a shell script #303

Open
jacobsalmela opened this issue Sep 12, 2023 · 1 comment
Open

Parameters:dynamic from a shell script #303

jacobsalmela opened this issue Sep 12, 2023 · 1 comment

Comments

@jacobsalmela
Copy link

Is it possible to somehow use dynamic parameters called from a shell script?

test_spec.sh

Describe 'complex matrix from external commands'

Parameters:dynamic
  "$SHELLSPEC_HELPERDIR/support/dynamic_matrix.sh"
End

It "does thing --with-param $2"
  BeforeCall $1
  When call bin/thing --with-param $2
  The status should equal $2
  The line 1 of stdout should equal "something"
End

End

dynamic_matrix.sh

array1=("a1" "b1")
array2=("a2" "b2")
for i in "${array1[@]}"; do
  for j in "${array2[@]}"; do
    # get data from either array
    var_from_array1=$(echo "$i" | awk '{print $1}')
    var_from_array2=$(echo "$j" | awk '{print $1}')
    echo %data "$var_from_array1" "$var_from_array2"  
  done
done

It looks like it runs some tests, but fails:

%data a1 a2
%data a1 b2
%data b1 a2
%data b1 b2

Unexpected error occurred (syntax error?) occurred in 'spec/complex.sh'
Running: /bin/sh [bash 3.2.57(1)-release]
...%data a1 a2
%data a1 b2
%data b1 a2
%data b1 b2
%data a1 a2
%data a1 b2
%data b1 a2
%data b1 b2
%data a1 a2
%data a1 b2
%data b1 a2
%data b1 b2
%data a1 a2
%data a1 b2
%data b1 a2
%data b1 b2
%data a1 a2
%data a1 b2
%data b1 a2
%data b1 b2
%data a1 a2
%data a1 b2
%data b1 a2
%data b1 b2
%data a1 a2
%data a1 b2
%data b1 a2
%data b1 b2
%data a1 a2
%data a1 b2
%data b1 a2
%data b1 b2
%data a1 a2
%data a1 b2
%data b1 a2
%data b1 b2
%data a1 a2
%data a1 b2
%data b1 a2
%data b1 b2
.....................................

Finished in 5.27 seconds (user 2.19 seconds, sys 1.09 seconds)
40 examples, 0 failures

Aborted with status code [executor: 0] [reporter: 0] [error handler: 102]
Fatal error occurred, terminated with exit status 102.
@jacobsalmela
Copy link
Author

Essentially, I want to feed the matrix with dynamic data from a script and then run several tasks.

Describe 'complex matrix from external commands'

Parameters:matrix
  foo bar
  for line in $(command --output); do
    %data $my $space $separated $output
  done
End

It "does thing --with-param $2"
  BeforeCall $1
  When call bin/thing --with-param $2
  The status should equal $2
  The line 1 of stdout should equal "something"
End

It "does more --with-param $3"
  When call bin/more --with-param $3
  The status should equal $2
End

End

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

1 participant