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 3
3
# # Any code here will be placed inside the `initialize()` function and called
4
4
# # before running anything else.
5
5
# #
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
+ # #
6
12
# # You can safely delete this file if you do not need it.
Original file line number Diff line number Diff line change 3
3
# # Any code here will be placed inside the `initialize()` function and called
4
4
# # before running anything else.
5
5
# #
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
+ # #
6
12
# # You can safely delete this file if you do not need it.
Original file line number Diff line number Diff line change 15
15
>
16
16
if Settings.enabled? :sourcing
17
17
> if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
18
- > {{ Settings.function_name :initialize }}
19
- > {{ Settings.function_name :run }} "$@"
18
+ = render(:start).indent 2
20
19
> fi
21
20
else
22
- > {{ Settings.function_name :initialize }}
23
- > {{ Settings.function_name :run }} "$@"
21
+ = render :start
24
22
end
25
23
>
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:
47
47
48
48
+ ./download something
49
49
./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
51
51
52
52
Stack 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 24
24
# Allow up to a certain string distance from the approval text in CI
25
25
leeway = ENV [ 'CI' ] ? 40 : 0
26
26
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
+
27
33
test_cases . each do |example |
28
34
approval_name = example . gsub 'spec/fixtures/workspaces' , 'fixtures'
29
35
41
47
# - The "+ ..." shell messages driven by `set -x` have no space
42
48
# - The order of our `inspect_args` sometimes differs
43
49
# - 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
45
57
end
46
58
end
47
59
end
Original file line number Diff line number Diff line change 11
11
lines = subject . code . split "\n "
12
12
expect ( lines [ 0 ..13 ] . join ( "\n " ) ) . to match_approval ( 'script/wrapper/code' )
13
13
. except ( /\d +\. \d +\. \d +(\. rc\d )?/ )
14
- expect ( lines [ -2 ] ) . to eq ' run "$@"'
14
+ expect ( lines [ -3 ] ) . to eq ' run "$@"'
15
15
end
16
16
end
17
17
You can’t perform that action at this time.
0 commit comments