File tree Expand file tree Collapse file tree 2 files changed +36
-10
lines changed Expand file tree Collapse file tree 2 files changed +36
-10
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ #
3+ # Helper functions for core library tests
4+
5+ declare -x _GO_CORE_STACK_TRACE_COMPONENTS=()
6+
7+ set_go_core_stack_trace_components () {
8+ local go_core_file=" $_GO_CORE_DIR /go-core.bash"
9+ local stack_item
10+ local IFS=$' \n '
11+
12+ if [[ " ${# _GO_CORE_STACK_TRACE_COMPONENTS[@]} " -ne ' 0' ]]; then
13+ return
14+ fi
15+
16+ create_test_go_script ' @go "$@"'
17+ create_test_command_script ' print-stack-trace' ' @go.print_stack_trace'
18+
19+ for stack_item in $( " $TEST_GO_SCRIPT " ' print-stack-trace' ) ; do
20+ if [[ " $stack_item " =~ $go_core_file ]]; then
21+ _GO_CORE_STACK_TRACE_COMPONENTS+=(" $stack_item " )
22+ elif [[ " ${# _GO_CORE_STACK_TRACE_COMPONENTS[@]} " -ne ' 0' ]]; then
23+ return
24+ fi
25+ done
26+ }
Original file line number Diff line number Diff line change 11#! /usr/bin/env bats
22
33load ../environment
4+ load helpers
45
56teardown () {
67 remove_test_go_rootdir
@@ -88,15 +89,14 @@ teardown() {
8889 ' bar_func'
8990
9091 run " $TEST_GO_SCRIPT " foo
91-
92- local go_core_pattern=" $_GO_CORE_DIR /go-core.bash:[0-9]+"
9392 assert_success
94- assert_line_equals 0 " $TEST_GO_SCRIPTS_DIR /foo.d/bar:5 source"
95- assert_line_matches 1 " $go_core_pattern _@go.run_command_script"
96- assert_line_matches 2 " $go_core_pattern @go"
97- assert_line_equals 3 " $TEST_GO_SCRIPTS_DIR /foo:3 foo_func"
98- assert_line_equals 4 " $TEST_GO_SCRIPTS_DIR /foo:5 source"
99- assert_line_matches 5 " $go_core_pattern _@go.run_command_script"
100- assert_line_matches 6 " $go_core_pattern @go"
101- assert_line_equals 7 " $TEST_GO_SCRIPT :3 main"
93+ set_go_core_stack_trace_components
94+
95+ local IFS=$' \n '
96+ assert_lines_equal " $TEST_GO_SCRIPTS_DIR /foo.d/bar:5 source" \
97+ " ${_GO_CORE_STACK_TRACE_COMPONENTS[@]} " \
98+ " $TEST_GO_SCRIPTS_DIR /foo:3 foo_func" \
99+ " $TEST_GO_SCRIPTS_DIR /foo:5 source" \
100+ " ${_GO_CORE_STACK_TRACE_COMPONENTS[@]} " \
101+ " $TEST_GO_SCRIPT :3 main"
102102}
You can’t perform that action at this time.
0 commit comments