Skip to content

Commit 3445ef5

Browse files
authored
refactor: optimize build script (#333)
1 parent b073e36 commit 3445ef5

File tree

3 files changed

+26
-17
lines changed

3 files changed

+26
-17
lines changed

.github/workflows/ci.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ jobs:
3636

3737
- uses: Swatinem/rust-cache@v2
3838

39+
- name: Install Bash 5 on macOS
40+
if: runner.os == 'macOS'
41+
run: |
42+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
43+
brew install bash
44+
bash --version
45+
3946
- name: Test
4047
run: cargo test --all
4148

src/build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ _argc_require_params() {
140140
r#"
141141
_argc_validate_choices() {
142142
local render_name="$1" raw_choices="$2" choices item choice concated_choices=""
143-
IFS=$'\n' read -r -d '' -a choices <<<"$raw_choices" || true
143+
while IFS= read -r line; do
144+
choices+=("$line")
145+
done <<<"$raw_choices"
144146
for choice in "${choices[@]}"; do
145147
if [[ -z "$concated_choices" ]]; then
146148
concated_choices="$choice"

tests/cli.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,22 @@ fn run_build() {
110110
.assert()
111111
.success();
112112

113-
// Command::cargo_bin("argc")
114-
// .unwrap()
115-
// .arg("--argc-run")
116-
// .arg(&outpath)
117-
// .args([
118-
// "--fa",
119-
// "--oa",
120-
// "oa1",
121-
// "--of=of1,of2",
122-
// "--oca=a",
123-
// "--ofa",
124-
// "abc",
125-
// ])
126-
// .assert()
127-
// .stdout(predicates::str::contains("argc__fn=main"))
128-
// .success();
113+
Command::cargo_bin("argc")
114+
.unwrap()
115+
.arg("--argc-run")
116+
.arg(&outpath)
117+
.args([
118+
"--fa",
119+
"--oa",
120+
"oa1",
121+
"--of=of1,of2",
122+
"--oca=a",
123+
"--ofa",
124+
"abc",
125+
])
126+
.assert()
127+
.stdout(predicates::str::contains("argc__fn=main"))
128+
.success();
129129
}
130130

131131
#[test]

0 commit comments

Comments
 (0)