split_tests icon indicating copy to clipboard operation
split_tests copied to clipboard

issues with argument parsing

Open ryanong opened this issue 2 years ago • 3 comments

So I'm writing some scripts and for some reason argument parsing is really difficult.

So looking at this code https://github.com/chaosaffe/split-tests/blob/main/action.yml#L61 for some reason the environment variables aren't parsed correctly. Specifically $EXCLUDE_GLOB

I have to eval them like this https://github.com/ryanong/split-tests/blob/patch-1/action.yml#L61 in order for the arguments to get consumed correctly. I have tried turning the arguments into a bash array but to application still messes up.

example broken code of array

ARGS=("--split-index=0" "--split-total=3" "--glob='spec/**/*_spec.rb'" "--junit" "--junit-path='report-tmp/rspec-*.xml'" "--exclude-glob='spec/features/**/*_spec.rb'")
echo $ARGS[@]
./split_tests $ARGS[@]

ryanong avatar Jan 17 '23 12:01 ryanong

shouldn't the command be ./split_tests $ARGS[*]? i am no expert on bash arrays, but google says so https://linuxhandbook.com/bash-arrays/

leonid-shevtsov avatar Jan 18 '23 08:01 leonid-shevtsov

Doesn't work either. Try locally

ryanong avatar Jan 18 '23 17:01 ryanong

so, coming back to this, sorry i can't pay more attention to this at the present... but looking at your source code - could it help if you pass the exclude-glob param, even if it's empty? basically as you are already doing with glob.

-glob='${{ inputs.glob }}' -exclude-glob='${{ inputs.exclude-glob }}'

it should just receive an empty string value for exclude-glob, and it's the same thing as not passing it. So technically, that should resolve this issue.

leonid-shevtsov avatar Feb 01 '23 21:02 leonid-shevtsov