Skip to content

Commit

Permalink
refactor: optimize build script (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed May 29, 2024
1 parent b073e36 commit 3445ef5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ jobs:

- uses: Swatinem/rust-cache@v2

- name: Install Bash 5 on macOS
if: runner.os == 'macOS'
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
brew install bash
bash --version
- name: Test
run: cargo test --all

Expand Down
4 changes: 3 additions & 1 deletion src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ _argc_require_params() {
r#"
_argc_validate_choices() {
local render_name="$1" raw_choices="$2" choices item choice concated_choices=""
IFS=$'\n' read -r -d '' -a choices <<<"$raw_choices" || true
while IFS= read -r line; do
choices+=("$line")
done <<<"$raw_choices"
for choice in "${choices[@]}"; do
if [[ -z "$concated_choices" ]]; then
concated_choices="$choice"
Expand Down
32 changes: 16 additions & 16 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,22 +110,22 @@ fn run_build() {
.assert()
.success();

// Command::cargo_bin("argc")
// .unwrap()
// .arg("--argc-run")
// .arg(&outpath)
// .args([
// "--fa",
// "--oa",
// "oa1",
// "--of=of1,of2",
// "--oca=a",
// "--ofa",
// "abc",
// ])
// .assert()
// .stdout(predicates::str::contains("argc__fn=main"))
// .success();
Command::cargo_bin("argc")
.unwrap()
.arg("--argc-run")
.arg(&outpath)
.args([
"--fa",
"--oa",
"oa1",
"--of=of1,of2",
"--oca=a",
"--ofa",
"abc",
])
.assert()
.stdout(predicates::str::contains("argc__fn=main"))
.success();
}

#[test]
Expand Down

0 comments on commit 3445ef5

Please sign in to comment.