Skip to content

Commit 7825906

Browse files
committed
test: Make tests run again
1 parent f51ec33 commit 7825906

13 files changed

+50
-28
lines changed

Diff for: basalt.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ description = ''
77

88
[run]
99
dependencies = []
10-
sourceDirs = ['pkg/lib/util', 'pkg/source']
10+
sourceDirs = ['pkg/lib', 'pkg/lib/public']
1111
builtinDirs = []
12-
binDirs = ['pkg/bin']
12+
binDirs = []
1313
completionDirs = []
1414
manDirs = []
1515

Diff for: examples/bashblog.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# https://github.com/cfenollosa/bashblog
44

5-
source bash-args parse <<"EOF"
5+
bash-args parse <<"EOF"
66
@arg post - insert a new blog post, or the filename of a draft to continue editing it. it tries to use markdown by default, and falls back to HTML if it's not available. use '-html' to override it and edit the post as HTML even when markdown is available
77
@arg edit - edit an already published .html or .md file. **NEVER** edit manually a published .html file, always use this function as it keeps internal data and rebuilds the blog. use '-n' to give the file a new name, if title was changed. use '-f' to edit full html file, instead of just text part (also preserves name)
88
@arg delete - deletes the post and rebuilds the blog

Diff for: examples/basher.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# https://github.com/basherpm/basher
44

5-
source bash-args parse parse <<"EOF"
5+
bash-args parse parse <<"EOF"
66
@arg help - Display help for a command
77
@arg commands - List all available basher commands
88
@arg init - Configure the shell environment for basher

Diff for: examples/bats.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# https://github.com/bats-core/bats-core
44

5-
source bash-args parse -- <<"EOF"
5+
bash-args parse -- <<"EOF"
66
@flag [count.c] - Count test cases without running any tests
77
@flag [filter.f] {} - Only run tests that match the regular expression
88
@flag [formatter.F] {pretty} - Swithc between formatters: pretty (default), tap (default w/o term), tap13, junit

Diff for: examples/json.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# https://github.com/dominictarr/JSON.sh
44

5-
source bash-args parse -- <<"EOF"
5+
bash-args parse -- <<"EOF"
66
@flag [.p] - Prune empty. Exclude fields with empty values.
77
@flag [.l] - Leaf only. Only show leaf nodes, which stops data duplication.
88
@flag [.b] - Brief. Combines 'Leaf only' and 'Prune empty' options.

Diff for: pkg/source/bash-args.sh renamed to pkg/lib/public/bash-args.sh

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ bash-args() {
7878
local flagValueDefault="${line##*\{}"; flagValueDefault="${flagValueDefault%%\}*}"
7979
local flagDescription="${line##* -}"
8080

81+
# TODO: nullglob
8182
# Ensure each variable is blank if parsing did not find anything. This corrects for parameter
8283
# expansion behavior, since no modifications to the original line if a match was not found
8384
if [ "$line" = "$flagNameOptional" ]; then flagNameOptional=; fi

Diff for: pkg/lib/util/util.sh renamed to pkg/lib/util.sh

File renamed without changes.

Diff for: tests/args.bats

+15-14
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/usr/bin/env bats
2-
set -Eeuo pipefail
2+
3+
load './util/init.sh'
34

45
@test "longOption with value" {
56
declare -A args=()
67

7-
source bash-args parse --port 3005 <<-'EOF'
8+
bash-args parse --port 3005 <<-'EOF'
89
@flag [port] {3000} - The port to open on
910
EOF
1011

@@ -16,7 +17,7 @@ set -Eeuo pipefail
1617
@test "shortOption with value" {
1718
declare -A args=()
1819

19-
source bash-args parse -p 3005 <<-'EOF'
20+
bash-args parse -p 3005 <<-'EOF'
2021
@flag [.p] {3000} - The port to open on
2122
EOF
2223

@@ -27,7 +28,7 @@ set -Eeuo pipefail
2728
@test "longOption and shortOption with longOption value" {
2829
declare -A args=()
2930

30-
source bash-args parse --port 3005 <<-'EOF'
31+
bash-args parse --port 3005 <<-'EOF'
3132
@flag [port.p] {3000} - The port to open on
3233
EOF
3334

@@ -41,7 +42,7 @@ set -Eeuo pipefail
4142
@test "longOption and shortOption with shortOption value" {
4243
declare -A args=()
4344

44-
source bash-args parse -p 3005 <<-'EOF'
45+
bash-args parse -p 3005 <<-'EOF'
4546
@flag [port.p] {3000} - The port to open on
4647
EOF
4748

@@ -58,7 +59,7 @@ set -Eeuo pipefail
5859

5960
declare -A args=()
6061

61-
source bash-args parse --version <<-'EOF'
62+
bash-args parse --version <<-'EOF'
6263
@flag [version.v] - The port to open on
6364
EOF
6465

@@ -69,7 +70,7 @@ set -Eeuo pipefail
6970
@test "longOption and default" {
7071
declare -A args=()
7172

72-
source bash-args parse <<-'EOF'
73+
bash-args parse <<-'EOF'
7374
@flag [port] {3000} - The port to open on
7475
EOF
7576

@@ -79,7 +80,7 @@ set -Eeuo pipefail
7980
@test "shortOption and default" {
8081
declare -A args=()
8182

82-
source bash-args parse <<-'EOF'
83+
bash-args parse <<-'EOF'
8384
@flag [.p] {3000} - The port to open on
8485
EOF
8586

@@ -89,7 +90,7 @@ set -Eeuo pipefail
8990
@test "longOption and shortOption" {
9091
declare -A args=()
9192

92-
source bash-args parse <<-'EOF'
93+
bash-args parse <<-'EOF'
9394
@flag [port.p] {3000} - The port to open on
9495
EOF
9596

@@ -103,7 +104,7 @@ set -Eeuo pipefail
103104
declare -A args=()
104105

105106
! (
106-
source bash-args parse --port --something nother <<-'EOF'
107+
bash-args parse --port --something nother <<-'EOF'
107108
@flag <port> {} - The port to open on
108109
EOF
109110
)
@@ -113,7 +114,7 @@ set -Eeuo pipefail
113114
declare -A args=()
114115

115116
(
116-
source bash-args parse --port --something nother <<-'EOF'
117+
bash-args parse --port --something nother <<-'EOF'
117118
@flag <port> - The port to open on
118119
@flag <something> - something
119120
EOF
@@ -124,7 +125,7 @@ set -Eeuo pipefail
124125
declare -A args=()
125126

126127
! (
127-
source bash-args parse --port - <<-'EOF'
128+
bash-args parse --port - <<-'EOF'
128129
@flag [port] {} - The port to open on
129130
EOF
130131
)
@@ -134,7 +135,7 @@ set -Eeuo pipefail
134135
declare -A args=()
135136

136137
(
137-
source bash-args parse --port - <<-'EOF'
138+
bash-args parse --port - <<-'EOF'
138139
@flag [port] - The port to open on
139140
EOF
140141
)
@@ -144,7 +145,7 @@ set -Eeuo pipefail
144145
declare -A args=()
145146

146147
! (
147-
source bash-args parse <<-'EOF'
148+
bash-args parse <<-'EOF'
148149
@flag <port> The port to open on
149150
EOF
150151
)

Diff for: tests/argsCommands.bats

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env bats
2-
set -Eeuo pipefail
2+
3+
load './util/init.sh'
34

45
@test "argsCommands is correct basic" {
56
declare -A args
67
declare -a argsCommands=()
78

8-
source bash-args parse alfa bravo <<-'EOF'
9+
bash-args parse alfa bravo <<-'EOF'
910
@flag [port.p] {3000} - The port to open on
1011
EOF
1112

@@ -19,7 +20,7 @@ set -Eeuo pipefail
1920
declare -A args
2021
declare -a argsCommands=()
2122

22-
source bash-args parse --port 3005 serve --user admin --enable-security now <<-'EOF'
23+
bash-args parse --port 3005 serve --user admin --enable-security now <<-'EOF'
2324
@flag [port.p] {3000} - The port to open on
2425
@flag [user] {} - User
2526
@flag [enable-security] - Enable security
@@ -34,7 +35,7 @@ set -Eeuo pipefail
3435
declare -A args
3536
declare -a argsCommands=()
3637

37-
source bash-args parse --port 3005 serve now --enable-security last <<-'EOF'
38+
bash-args parse --port 3005 serve now --enable-security last <<-'EOF'
3839
@flag [port.p] {3000} - The port to open on
3940
@flag [enable-security] - Whether to enable security
4041
EOF

Diff for: tests/argsPostHyphen.bats

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env bash
2-
set -Eeuo pipefail
2+
3+
load './util/init.sh'
34

45
@test "append to post argsPostHyphen if set" {
56
declare -A args=()
67
declare -a argsPostHyphen=()
78

8-
source bash-args parse "--port" "3005" -- one two <<-'EOF'
9+
bash-args parse "--port" "3005" -- one two <<-'EOF'
910
@flag [port] {3000} - The port to open on
1011
EOF
1112

Diff for: tests/argsRawSpec.bats

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/usr/bin/env bats
2-
set -Eeuo pipefail
2+
3+
load './util/init.sh'
34

45
@test "correct argsRawSpec value" {
56
declare -A args=()
67
declare argsRawSpec=
78

8-
source bash-args parse "--port" "3005" -- one two <<-'EOF'
9+
bash-args parse "--port" "3005" -- one two <<-'EOF'
910
@flag [port] {3000} - The port to open on
1011
EOF
1112

Diff for: tests/util/init.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# shellcheck shell=bash
2+
# TODO
3+
set -Eeo pipefail
4+
5+
eval "$(basalt-package-init)"; basalt.package-init
6+
basalt.package-load
7+
8+
load './util/test_util.sh'
9+
10+
setup() {
11+
cd "$BATS_TEST_TMPDIR"
12+
}
13+
14+
teardown() {
15+
cd "$BATS_SUITE_TMPDIR"
16+
}

Diff for: tests/util/test_util.sh

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# shellcheck shell=bash

0 commit comments

Comments
 (0)