Skip to content

Commit ee7c1b2

Browse files
committed
Update Bugfix
1 parent 24ba09b commit ee7c1b2

File tree

15 files changed

+353
-104
lines changed

15 files changed

+353
-104
lines changed

opensearch

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,12 +1078,12 @@ GETOPTIONSHERE
10781078
eval "set -- ${xmlFiles}"
10791079

10801080
for xmlFile in ${@+"${@}"}; do
1081-
opensearch_file_check --err --quiet "${xmlFile}" || skip_error "${skipFlag}" 'status' "${EX_DATAERR}"
1081+
opensearch_file_check --err --quiet "${xmlFile}" || eval "$(skip_error "${skipFlag}" 'status' "${EX_DATAERR}")"
10821082

10831083
if ! email="$(opensearch_select --value-of 'normalize-space(os:Contact)' "${xmlFile}")"; then
10841084
printf "%s: '%s' に連絡先が存在しません。\\n" "${0##*/}" "${xmlFile}" >&2
10851085

1086-
skip_error "${skipFlag}" 'status' "${EX_DATAERR}"
1086+
eval "$(skip_error "${skipFlag}" 'status' "${EX_DATAERR}")"
10871087
fi
10881088

10891089
append_array_posix 'emails' "${email}"
@@ -2374,15 +2374,15 @@ GETOPTIONSHERE
23742374
eval "set -- ${xmlFiles}"
23752375

23762376
for xmlFile in ${@+"${@}"}; do
2377-
opensearch_file_check --err --quiet "${xmlFile}" || skip_error "${skipFlag}" 'status' "${EX_DATAERR}"
2377+
opensearch_file_check --err --quiet "${xmlFile}" || eval "$(skip_error "${skipFlag}" 'status' "${EX_DATAERR}")"
23782378

23792379
if [ "${argCount}" -ne '0' ] || ! url=$(opensearch_normalize "${xmlFile}" | opensearch_select --value-of 'moz:SearchForm' -); then
23802380
url=$(
23812381
opensearch_normalize "${xmlFile}" \
23822382
| opensearch_url_element_to_tsv - 'results' \
23832383
| eval tsv_select_url \
23842384
'"${xmlFile}"' '"${mimeType}"' "${parameters}"
2385-
) || skip_error "${skipFlag}" 'status' "${?}"
2385+
) || eval "$(skip_error "${skipFlag}" 'status' "${EX_DATAERR}")"
23862386
fi
23872387

23882388
append_array_posix 'urls' "${url}"
@@ -2567,7 +2567,7 @@ GETOPTIONSHERE
25672567
xmlFileCount="${#}"
25682568

25692569
for xmlFile in ${@+"${@}"}; do
2570-
opensearch_file_check --err --quiet "${xmlFile}" || skip_error "${skipFlag}" 'status' "${EX_DATAERR}"
2570+
opensearch_file_check --err --quiet "${xmlFile}" || eval "$(skip_error "${skipFlag}" 'status' "${EX_DATAERR}")"
25712571

25722572
if [ '2' -le "${xmlFileCount}" ]; then
25732573
printf -- '--- # %s\n' "${xmlFile}"
@@ -2732,7 +2732,7 @@ GETOPTIONSHERE
27322732
for xmlFile in ${@+"${@}"}; do
27332733
index=$((${index:-0} + 1))
27342734

2735-
opensearch_file_check --err --quiet "${xmlFile}" || skip_error "${skipFlag}" 'status' "${EX_DATAERR}"
2735+
opensearch_file_check --err --quiet "${xmlFile}" || eval "$(skip_error "${skipFlag}" 'status' "${EX_DATAERR}")"
27362736

27372737
downloadXML="${tmpDir}/download${index}.xml"
27382738
url=$(
@@ -2742,7 +2742,7 @@ GETOPTIONSHERE
27422742
'"${xmlFile}"' \
27432743
'"${OPENSEARCH_MIME_TYPES}"' \
27442744
"${parameters}"
2745-
) || skip_error "${skipFlag}" 'status' "${?}"
2745+
) || eval "$(skip_error "${skipFlag}" 'status' "${EX_DATAERR}")"
27462746

27472747
if
27482748
download "${downloadXML}" "${url}" "${OPENSEARCH_MIME_TYPES}" \
@@ -2754,7 +2754,7 @@ GETOPTIONSHERE
27542754
printf "%s: %s は OpenSearch description document ではありません。\\n" "${0##*/}" "${url}" >&2
27552755

27562756
rm -f -- "${downloadXML}"
2757-
skip_error "${skipFlag}" 'status' "${EX_DATAERR}"
2757+
eval "$(skip_error "${skipFlag}" 'status' "${EX_DATAERR}")"
27582758
fi
27592759
done
27602760

@@ -2941,8 +2941,8 @@ GETOPTIONSHERE
29412941

29422942
skip_error() {
29432943
case "${1}" in
2944-
'1') eval "${2}=\"\${3}\"; continue";;
2945-
*) end_call "${3}"
2944+
'1') printf "%s='%s'; continue" "${2}" "${3}";;
2945+
*) printf "end_call '%d'" "${3}";;
29462946
esac
29472947
}
29482948

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#!/usr/bin/env sh
22

3-
### File: opensearch-general_spec.sh
3+
### File: opensearch-base_spec.sh
44
##
5-
## opensearch のベーステスト
5+
## opensearch のテスト
66
##
77
## Usage:
88
##
99
## ------ Text ------
10-
## shellspec opensearch-general_spec.sh
10+
## shellspec opensearch-base_spec.sh
1111
## ------------------
1212
##
1313
## Metadata:
@@ -38,7 +38,7 @@ Describe 'opensearch base test'
3838
'nil' '' '1' '64'
3939
End
4040

41-
Example "./openseaarch ${1}"
41+
Example "./openseaarch '${1}'"
4242
When call ./opensearch ${1}
4343
The length of stdout should ${2:+'not'} eq 0
4444
The length of stderr should ${3:+'not'} eq 0

spec/opensearch-contact_spec.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### File: opensearch-contact_spec.sh
44
##
5-
## opensearch contact テスト
5+
## opensearch contact のテスト
66
##
77
## Usage:
88
##
@@ -50,7 +50,7 @@ Describe 'opensearch contact test'
5050
}
5151

5252
setup() {
53-
configDir="${PWD}/spec/.shell-opensearch"
53+
configDir='./spec/.shell-opensearch'
5454
5555
}
5656

@@ -67,14 +67,14 @@ Describe 'opensearch contact test'
6767
When call ./opensearch contact --nil
6868
The length of stdout should eq 0
6969
The length of stderr should not eq 0
70-
The status should eq 64
70+
The status should eq 64
7171
End
7272

7373
Example '2個以上の引数'
7474
When call ./opensearch contact simple detailed
7575
The length of stdout should eq 0
7676
The length of stderr should not eq 0
77-
The status should eq 64
77+
The status should eq 64
7878
End
7979

8080
Describe '基本となるテスト'

spec/opensearch-list_spec.sh

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### File: opensearch-list_spec.sh
44
##
5-
## opensearch list テスト
5+
## opensearch list のテスト
66
##
77
## Usage:
88
##
@@ -27,34 +27,34 @@
2727

2828
eval "$(shellspec - -c) exit 1"
2929

30-
Describe 'opensearch validate test'
31-
title_check() {
32-
eval "set -- ${1}"
30+
Describe 'opensearch list test'
31+
name_check() {
32+
eval "set -- ${1}"
3333

34-
printf '%s' "${line_check}" | awk -- "$(
35-
cat <<-'__EOF__'
36-
BEGIN {
37-
split("", arguments)
34+
printf '%s' "${line_check}" | awk -- "$(
35+
cat <<-'__EOF__'
36+
BEGIN {
37+
split("", arguments)
3838
39-
for(i = 1; i < ARGC; i++) {
40-
arguments[i] = ": " ARGV[i]
41-
delete ARGV[i]
42-
}
39+
for(i = 1; i < ARGC; i++) {
40+
arguments[i] = ": " ARGV[i]
41+
delete ARGV[i]
4342
}
43+
}
4444
45-
!arguments[NR] || substr($0, length($0) - length(arguments[NR]) + 1) != arguments[NR] {
46-
exit 1
47-
}
48-
__EOF__
49-
)" ${@+"${@}"}
50-
}
45+
!arguments[NR] || substr($0, length($0) - length(arguments[NR]) + 1) != arguments[NR] {
46+
exit 1
47+
}
48+
__EOF__
49+
)" ${@+"${@}"}
50+
}
5151

52-
setup() {
53-
configDir="${PWD}/spec/.shell-opensearch"
54-
title="'Web Search'"
55-
}
52+
setup() {
53+
configDir='./spec/.shell-opensearch'
54+
name="'Web Search'"
55+
}
5656

57-
BeforeAll 'setup'
57+
BeforeAll 'setup'
5858

5959
Example 'オプション -h のテスト'
6060
When call ./opensearch list -h
@@ -79,42 +79,42 @@ Describe 'opensearch validate test'
7979

8080
Describe 'OpenSearch ファイルを指定'
8181
Parameters:block
82-
'simple' "${title}" '' '0'
83-
'detailed' "${title}" '' '0'
82+
'simple' "${name}" '' '0'
83+
'detailed' "${name}" '' '0'
8484
'empty' '' '1' '65'
8585
'draft2' '' '1' '65'
8686
'nil' '' '1' '65'
87-
'success/' "${title} ${title}" '' '0'
88-
'failure/' '' '1' '65'
89-
'empty/' '' '' '0'
90-
'nil/' '' '' '0'
91-
'simple,detailed' "${title} ${title}" '' '0'
92-
'simple,nil' "${title}" '1' '65'
93-
'draft2,nil' '' '1' '65'
94-
'draft2,nil,simple' "${title}" '1' '65'
95-
'./spec/.shell-opensearch/simple.xml' "${title}" '' '0'
96-
'./spec/.shell-opensearch/detailed.xml' "${title}" '' '0'
97-
'./spec/.shell-opensearch/empty.xml' '' '1' '65'
98-
'./spec/.shell-opensearch/draft2.xml' '' '1' '65'
99-
'./spec/.shell-opensearch/nil.xml' '' '1' '65'
87+
'success/' "${name} ${name}" '' '0'
88+
'failure/' '' '1' '65'
89+
'empty/' '' '' '0'
90+
'nil/' '' '' '0'
91+
'simple,detailed' "${name} ${name}" '' '0'
92+
'simple,nil' "${name}" '1' '65'
93+
'draft2,nil' '' '1' '65'
94+
'draft2,nil,simple' "${name}" '1' '65'
95+
'./spec/.shell-opensearch/simple.xml' "${name}" '' '0'
96+
'./spec/.shell-opensearch/detailed.xml' "${name}" '' '0'
97+
'./spec/.shell-opensearch/empty.xml' '' '1' '65'
98+
'./spec/.shell-opensearch/draft2.xml' '' '1' '65'
99+
'./spec/.shell-opensearch/nil.xml' '' '1' '65'
100100
End
101101

102102
Example "オプションなしのテスト: '${1}'"
103103
When run source ./opensearch -c "${configDir}" list "${1}"
104104
The lines of stdout should eq "$(eval "set -- ${2}"; printf '%d' "${#}")"
105-
The stdout should satisfy title_check "${2}"
105+
The stdout should satisfy name_check "${2}"
106106
The length of stderr should ${3:+'not'} eq 0
107107
The status should eq "${4}"
108108
End
109109

110110
Example "オプション -p のテスト: '${1}'"
111111
path_check() {
112-
printf '%s' "${path_check}" | awk -- 'index($0, "/") != 1 && index($0, "./") != 1 { exit 1 }'
112+
printf '%s' "${path_check}" | awk -- 'index($0, "/") != 1 && index($0, "./") != 1 { exit 1; }'
113113
}
114114

115115
When run source ./opensearch -c "${configDir}" list -p "${1}"
116116
The lines of stdout should eq "$(eval "set -- ${2}"; printf '%d' "${#}")"
117-
The stdout should satisfy title_check "${2}"
117+
The stdout should satisfy name_check "${2}"
118118
The stdout should satisfy path_check
119119
The length of stderr should ${3:+'not'} eq 0
120120
The status should eq "${4}"

spec/opensearch-show_spec.sh

Lines changed: 38 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### File: opensearch-show_spec.sh
44
##
5-
## opensearch show テスト
5+
## opensearch show のテスト
66
##
77
## Usage:
88
##
@@ -28,30 +28,8 @@
2828
eval "$(shellspec - -c) exit 1"
2929

3030
Describe 'opensearch show test'
31-
email_check() {
32-
eval "set -- ${1}"
33-
34-
printf '%s' "${email_check}" | awk -- "$(
35-
cat <<-'__EOF__'
36-
BEGIN {
37-
split("", arguments)
38-
39-
for(i = 1; i < ARGC; i++) {
40-
arguments[i] = ARGV[i]
41-
delete ARGV[i]
42-
}
43-
}
44-
45-
!(NR in arguments) || $0 != arguments[NR] {
46-
exit 1
47-
}
48-
__EOF__
49-
)" ${@+"${@}"}
50-
}
51-
5231
setup() {
53-
configDir="${PWD}/spec/.shell-opensearch"
54-
32+
configDir='./spec/.shell-opensearch'
5533
}
5634

5735
BeforeAll 'setup'
@@ -67,41 +45,58 @@ Describe 'opensearch show test'
6745
When call ./opensearch show --nil
6846
The length of stdout should eq 0
6947
The length of stderr should not eq 0
70-
The status should eq 64
48+
The status should eq 64
7149
End
7250

7351
Example '2個以上の引数'
7452
When call ./opensearch show simple detailed
7553
The length of stdout should eq 0
7654
The length of stderr should not eq 0
77-
The status should eq 64
55+
The status should eq 64
56+
End
57+
58+
Example "オプション -f nil のテスト: '${1}'"
59+
When call ./opensearch -c "${configDir}" show -f nil
60+
The length of stdout should eq 0
61+
The length of stderr should not eq 0
62+
The status should eq 64
7863
End
7964

8065
Describe '基本となるテスト'
8166
Parameters:block
82-
'minimum' '' '' '0'
83-
'simple' '1' '' '0'
84-
'empty' '' '1' '65'
85-
'draft2' '' '1' '65'
86-
'nil' '' '1' '65'
87-
'success/' '1' '' '0'
88-
'failure/' '' '1' '65'
89-
'empty/' '' '' '0'
90-
'nil/' '' '' '0'
91-
'simple,detailed' '1' '' '0'
92-
'simple,minimum' '' '' '0'
67+
'simple' 'simple' '' '0'
68+
'detailed' 'detailed' '' '0'
69+
'empty' '' '1' '65'
70+
'draft2' '' '1' '65'
71+
'nil' '' '1' '65'
72+
'empty/' '' '' '0'
73+
'nil/' '' '' '0'
74+
'simple,detailed' 'simple-detailed' '' '0'
9375
'simple,nil' '' '1' '65'
9476
'draft2,nil' '' '1' '65'
95-
'./spec/.shell-opensearch/simple.xml' "1" '' '0'
96-
'./spec/.shell-opensearch/minimul.xml' '' '1' '65'
97-
'./spec/.shell-opensearch/empty.xml' '' '1' '65'
98-
'./spec/.shell-opensearch/nil.xml' '' '1' '65'
77+
'./spec/.shell-opensearch/simple.xml' 'simple' '' '0'
78+
'./spec/.shell-opensearch/detailed.xml' 'detailed' '' '0'
79+
'./spec/.shell-opensearch/empty.xml' '' '1' '65'
80+
'./spec/.shell-opensearch/nil.xml' '' '1' '65'
9981
End
10082

10183
Example "オプションなしのテスト: '${1}'"
10284
When call ./opensearch -c "${configDir}" show "${1}"
103-
#The lines of stdout should eq "$(eval "set -- ${2}"; printf '%d' "${#}")"
104-
#The stdout should satisfy email_check "${2}"
85+
The stdout should eq "$(cd -- 'spec/show-text'; : | eval "cat -- ${2}")"
86+
The length of stderr should ${3:+'not'} eq 0
87+
The status should eq "${4}"
88+
End
89+
90+
Example "オプション -f xml のテスト: '${1}'"
91+
When call ./opensearch -c "${configDir}" show -f xml "${1}"
92+
The stdout should eq "$(cd -- 'spec/show-xml'; : | eval "cat -- ${2}")"
93+
The length of stderr should ${3:+'not'} eq 0
94+
The status should eq "${4}"
95+
End
96+
97+
Example "オプション -f normalized-xml のテスト: '${1}'"
98+
When call ./opensearch -c "${configDir}" show -f normalized-xml "${1}"
99+
The stdout should eq "$(cd -- 'spec/show-normalized-xml'; : | eval "cat -- ${2}")"
105100
The length of stderr should ${3:+'not'} eq 0
106101
The status should eq "${4}"
107102
End

0 commit comments

Comments
 (0)