File tree Expand file tree Collapse file tree 7 files changed +40
-10
lines changed
Expand file tree Collapse file tree 7 files changed +40
-10
lines changed Original file line number Diff line number Diff line change 33# # Any code here will be placed inside the `initialize()` function and called
44# # before running anything else.
55# #
6+ # # - The raw command line arguments are available to you here as "$@"
7+ # # - If you wish to override the raw arguments before they are processed,
8+ # # simply define an array named `input_override`:
9+ # #
10+ # # declare -g -a input_override=("modified" "args")
11+ # #
612# # You can safely delete this file if you do not need it.
Original file line number Diff line number Diff line change 33# # Any code here will be placed inside the `initialize()` function and called
44# # before running anything else.
55# #
6+ # # - The raw command line arguments are available to you here as "$@"
7+ # # - If you wish to override the raw arguments before they are processed,
8+ # # simply define an array named `input_override`:
9+ # #
10+ # # declare -g -a input_override=("modified" "args")
11+ # #
612# # You can safely delete this file if you do not need it.
Original file line number Diff line number Diff line change 1515>
1616if Settings.enabled? :sourcing
1717 > if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
18- > {{ Settings.function_name :initialize }}
19- > {{ Settings.function_name :run }} "$@"
18+ = render(:start).indent 2
2019 > fi
2120else
22- > {{ Settings.function_name :initialize }}
23- > {{ Settings.function_name :run }} "$@"
21+ = render :start
2422end
2523>
Original file line number Diff line number Diff line change 1+ = view_marker
2+
3+ > {{ Settings.function_name :initialize }} "$@"
4+ > if declare -p input_override &>/dev/null; then
5+ > {{ Settings.function_name :run }} "${input_override[@]}"
6+ > else
7+ > {{ Settings.function_name :run }} "$@"
8+ > fi
Original file line number Diff line number Diff line change @@ -47,9 +47,9 @@ Examples:
4747
4848+ ./download something
4949./download: line 15: no_such_command: command not found
50- ./download:15 in `root_command`: no_such_command
50+ ./download:<line> in `root_command`: no_such_command
5151
5252Stack trace:
53- from ./download:15 in `root_command`
54- from ./download:259 in `run`
55- from ./download:265 in `main`
53+ from ./download:<line> in `root_command`
54+ from ./download:<line> in `run`
55+ from ./download:<line> in `main`
Original file line number Diff line number Diff line change 2424 # Allow up to a certain string distance from the approval text in CI
2525 leeway = ENV [ 'CI' ] ? 40 : 0
2626
27+ # For certain examples, allow some exceptions (replacements) since they
28+ # are too volatile (e.g. line number changes)
29+ exceptions = {
30+ 'examples/stacktrace' => [ /download:\d +/ , 'download:<line>' ]
31+ }
32+
2733 test_cases . each do |example |
2834 approval_name = example . gsub 'spec/fixtures/workspaces' , 'fixtures'
2935
4147 # - The "+ ..." shell messages driven by `set -x` have no space
4248 # - The order of our `inspect_args` sometimes differs
4349 # - The result of the `deps` array sometimes differs
44- expect ( output ) . to match_approval ( approval_name ) . diff ( leeway )
50+ # In addition, for some examples we allow exceptions, so the below is
51+ # just a more granular version of:
52+ # expect(output).to match_approval(approval_name).diff(leeway).except(*except)
53+ match_output = match_approval ( approval_name ) . diff ( leeway )
54+ except = exceptions [ example ]
55+ match_output = match_output . except ( *except ) if except
56+ expect ( output ) . to match_output
4557 end
4658 end
4759 end
Original file line number Diff line number Diff line change 1111 lines = subject . code . split "\n "
1212 expect ( lines [ 0 ..13 ] . join ( "\n " ) ) . to match_approval ( 'script/wrapper/code' )
1313 . except ( /\d +\. \d +\. \d +(\. rc\d )?/ )
14- expect ( lines [ -2 ] ) . to eq ' run "$@"'
14+ expect ( lines [ -3 ] ) . to eq ' run "$@"'
1515 end
1616 end
1717
You can’t perform that action at this time.
0 commit comments