From 1e8fb435e35c8a7d5df91937e6aad629d2ad0116 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Sat, 13 Jan 2024 10:36:44 -0800 Subject: [PATCH 1/5] ci: Run on macOS --- .github/workflows/ci.yml | 26 ++++++++++----------- functions/_pure_check_for_new_release.fish | 2 +- tests/_pure_check_for_new_release.test.fish | 2 ++ tests/_pure_is_inside_container.test.fish | 8 +++++-- tests/_pure_print_prompt_rows.test.fish | 4 ++-- tests/_pure_prompt_new_line.test.fish | 6 ++--- tests/fish_prompt.test.fish | 4 ++-- 7 files changed, 29 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2dec2914..e5d520a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,19 +56,19 @@ jobs: - run: docker --version - run: make test-pure-on-nix FISH_VERSION=${{ matrix.version.fish }} - # test-macos: - # name: Test on fish on MacOS - # runs-on: macos-latest - # steps: - # - uses: actions/checkout@v2 - # - name: Install Fish - # run: brew install fish - # - name: Install Fisher > Fishtape > Pure - # run: curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher jorgebucaran/fishtape ./ - # shell: fish {0} - # - name: Test Pure - # run: fishtape tests/*.test.fish - # shell: fish {0} + test-macos: + name: Test on fish on MacOS + runs-on: macos-latest + steps: + - uses: actions/checkout@v2 + - name: Install Fish + run: brew install fish + - name: Install Fisher > Fishtape > Pure + run: curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher jorgebucaran/fishtape ./ + shell: fish {0} + - name: Test Pure + run: fishtape tests/*.test.fish + shell: fish {0} bump-version: # Bump when on master needs: [test-container] diff --git a/functions/_pure_check_for_new_release.fish b/functions/_pure_check_for_new_release.fish index a1749391..9704bc80 100644 --- a/functions/_pure_check_for_new_release.fish +++ b/functions/_pure_check_for_new_release.fish @@ -20,5 +20,5 @@ function pure_get_latest_release_version \ curl \ --silent \ "https://api.github.com/repos/$user_repo/releases/latest" \ - | string match --regex '"tag_name": "\K.*?(?=")' + | string match --regex '"tag_name": "\K.*?(?=")' end diff --git a/tests/_pure_check_for_new_release.test.fish b/tests/_pure_check_for_new_release.test.fish index e6a84c90..976e650c 100644 --- a/tests/_pure_check_for_new_release.test.fish +++ b/tests/_pure_check_for_new_release.test.fish @@ -20,6 +20,7 @@ before_each before_each @test "_pure_check_for_new_release: nothing when same as latest" ( set --universal pure_check_for_new_release true + set --erase pure_version set --universal pure_version 0.0.1 function curl; echo '"tag_name": "v0.0.1",'; end # mock @@ -29,6 +30,7 @@ before_each before_each @test "_pure_check_for_new_release: show fisher command to install when enable" ( set --universal pure_check_for_new_release true + set --erase pure_version set --universal pure_version 0.0.1 function curl; echo '"tag_name": "v9.9.9",'; end # mock diff --git a/tests/_pure_is_inside_container.test.fish b/tests/_pure_is_inside_container.test.fish index f1886113..892c7417 100644 --- a/tests/_pure_is_inside_container.test.fish +++ b/tests/_pure_is_inside_container.test.fish @@ -54,11 +54,15 @@ end ) = once cleanup_spy -@test "_pure_is_inside_container: true for Github Action" ( +@test "_pure_is_inside_container: false for Github Action" ( set --universal pure_enable_container_detection true _pure_is_inside_container -) $status -eq $SUCCESS +) $status -eq (if test (uname) = Darwin + echo $FAILURE +else + echo $SUCCESS +end) @test "_pure_is_inside_container: detect with $container variable" ( set --universal pure_enable_container_detection true diff --git a/tests/_pure_print_prompt_rows.test.fish b/tests/_pure_print_prompt_rows.test.fish index 3108eb14..f30f0197 100644 --- a/tests/_pure_print_prompt_rows.test.fish +++ b/tests/_pure_print_prompt_rows.test.fish @@ -19,14 +19,14 @@ before_each @test "_pure_print_prompt_rows: end with newline by default" ( set --universal pure_enable_single_line_prompt false - _pure_print_prompt_rows | wc -l + _pure_print_prompt_rows | wc -l | tr -d ' ' ) = $IS_PRESENT before_each @test "_pure_print_prompt_rows: end WITHOUT newline when compact-prompt is enable" ( set --universal pure_enable_single_line_prompt true - _pure_print_prompt_rows | wc -l + _pure_print_prompt_rows | wc -l | tr -d ' ' ) = $NONE diff --git a/tests/_pure_prompt_new_line.test.fish b/tests/_pure_prompt_new_line.test.fish index 32f0e4f4..f350cddf 100644 --- a/tests/_pure_prompt_new_line.test.fish +++ b/tests/_pure_prompt_new_line.test.fish @@ -22,21 +22,21 @@ end set --universal pure_enable_single_line_prompt false set _pure_fresh_session false - _pure_prompt_new_line | wc -l + _pure_prompt_new_line | wc -l | tr -d ' ' ) -eq $IS_PRESENT @test "_pure_prompt_new_line: print prompt without newline for new session" ( set --universal pure_enable_single_line_prompt false set _pure_fresh_session true - _pure_prompt_new_line | wc -l + _pure_prompt_new_line | wc -l | tr -d ' ' ) = $NONE @test "_pure_prompt_new_line: print prompt without newline when single line prompt is enabled" ( set _pure_fresh_session false set --universal pure_enable_single_line_prompt true - _pure_prompt_new_line | wc -l + _pure_prompt_new_line | wc -l | tr -d ' ' ) = $NONE before_each diff --git a/tests/fish_prompt.test.fish b/tests/fish_prompt.test.fish index f196015a..06231f60 100644 --- a/tests/fish_prompt.test.fish +++ b/tests/fish_prompt.test.fish @@ -61,13 +61,13 @@ before_all @test "fish_prompt: use 2-lines prompt by default" ( set --universal pure_enable_single_line_prompt false - fish_prompt | wc -l + fish_prompt | wc -l | tr -d ' ' ) = 2 @test "fish_prompt: use 1-line compact-prompt" ( set --universal pure_enable_single_line_prompt true - fish_prompt | wc -l + fish_prompt | wc -l | tr -d ' ' ) = 1 after_all From f1c5f435b7095fc5ded8df274e479b31416c8a35 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Tue, 23 Jan 2024 19:40:25 -0800 Subject: [PATCH 2/5] ci: Specify macOS fish version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5d520a7..70776608 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Install Fish - run: brew install fish + run: brew install fish@3.3.1 - name: Install Fisher > Fishtape > Pure run: curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher jorgebucaran/fishtape ./ shell: fish {0} From fb0fad132dd2ce06697f2a7783b32237d838ef48 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Tue, 23 Jan 2024 19:45:16 -0800 Subject: [PATCH 3/5] test: Write dedicated container tests for each platform --- tests/_pure_is_inside_container.test.fish | 27 +++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/tests/_pure_is_inside_container.test.fish b/tests/_pure_is_inside_container.test.fish index 892c7417..8f24f6da 100644 --- a/tests/_pure_is_inside_container.test.fish +++ b/tests/_pure_is_inside_container.test.fish @@ -53,16 +53,25 @@ end echo $called ) = once -cleanup_spy -@test "_pure_is_inside_container: false for Github Action" ( - set --universal pure_enable_container_detection true +if test (uname -s) != Darwin + cleanup_spy + @test "_pure_is_inside_container: true for Github Action on Ubuntu" ( + set --universal pure_enable_container_detection true - _pure_is_inside_container -) $status -eq (if test (uname) = Darwin - echo $FAILURE -else - echo $SUCCESS -end) + _pure_is_inside_container + ) $status -eq $SUCCESS + end +end + +if test (uname -s) = Darwin + cleanup_spy + @test "_pure_is_inside_container: false for Github Action on MacOS" ( + set --universal pure_enable_container_detection true + + _pure_is_inside_container + ) $status -eq $FAILURE + end +end @test "_pure_is_inside_container: detect with $container variable" ( set --universal pure_enable_container_detection true From ad886edbd4f16d7eebab8fccc818b13e855cac55 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Tue, 23 Jan 2024 19:50:37 -0800 Subject: [PATCH 4/5] Revert "ci: Specify macOS fish version" This reverts commit f1c5f435b7095fc5ded8df274e479b31416c8a35. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 70776608..e5d520a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,7 +62,7 @@ jobs: steps: - uses: actions/checkout@v2 - name: Install Fish - run: brew install fish@3.3.1 + run: brew install fish - name: Install Fisher > Fishtape > Pure run: curl -sL https://git.io/fisher | source && fisher install jorgebucaran/fisher jorgebucaran/fishtape ./ shell: fish {0} From 259702e714865c4b8322589a5926b4793da5d6a7 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Sun, 4 Feb 2024 00:33:19 -0800 Subject: [PATCH 5/5] Remove extraneous `end` --- tests/_pure_is_inside_container.test.fish | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/_pure_is_inside_container.test.fish b/tests/_pure_is_inside_container.test.fish index 8f24f6da..0bf88b55 100644 --- a/tests/_pure_is_inside_container.test.fish +++ b/tests/_pure_is_inside_container.test.fish @@ -60,7 +60,6 @@ if test (uname -s) != Darwin _pure_is_inside_container ) $status -eq $SUCCESS - end end if test (uname -s) = Darwin @@ -68,9 +67,8 @@ if test (uname -s) = Darwin @test "_pure_is_inside_container: false for Github Action on MacOS" ( set --universal pure_enable_container_detection true - _pure_is_inside_container + _pure_is_inside_container ) $status -eq $FAILURE - end end @test "_pure_is_inside_container: detect with $container variable" (