From f510a4def638b03e9001237e62e5ed2a2bcea2c6 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 17 Aug 2024 18:23:42 +0900 Subject: [PATCH] Test cases for non-default --scheme options --- .github/workflows/linux.yml | 2 +- .rubocop.yml | 4 ++-- Makefile | 7 +++++-- test/test_go.rb | 12 ++++++++---- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 63a80e84..e4117238 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -36,7 +36,7 @@ jobs: run: sudo apt-get install --yes zsh fish tmux - name: Install Ruby gems - run: sudo gem install --no-document minitest:5.17.0 rubocop:1.43.0 rubocop-minitest:0.25.1 rubocop-performance:1.15.2 + run: sudo gem install --no-document minitest:5.25.1 rubocop:1.65.0 rubocop-minitest:0.35.1 rubocop-performance:1.21.1 - name: Rubocop run: rubocop --require rubocop-minitest --require rubocop-performance diff --git a/.rubocop.yml b/.rubocop.yml index 80baa491..28d8a340 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -6,7 +6,7 @@ Lint/ShadowingOuterLocalVariable: Enabled: false Style/MethodCallWithArgsParentheses: Enabled: true - IgnoredMethods: + AllowedMethods: - assert - exit - paste @@ -15,7 +15,7 @@ Style/MethodCallWithArgsParentheses: - refute - require - send_keys - IgnoredPatterns: + AllowedPatterns: - ^assert_ - ^refute_ Style/NumericPredicate: diff --git a/Makefile b/Makefile index 56bb1c1e..7c6bd54b 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,6 @@ endif all: target/$(BINARY) test: $(SOURCES) - [ -z "$$(gofmt -s -d src)" ] || (gofmt -s -d src; exit 1) SHELL=/bin/sh GOOS= $(GO) test -v -tags "$(TAGS)" \ github.com/junegunn/fzf/src \ github.com/junegunn/fzf/src/algo \ @@ -87,6 +86,10 @@ test: $(SOURCES) bench: cd src && SHELL=/bin/sh GOOS= $(GO) test -v -tags "$(TAGS)" -run=Bench -bench=. -benchmem +lint: $(SOURCES) test/test_go.rb + [ -z "$$(gofmt -s -d src)" ] || (gofmt -s -d src; exit 1) + rubocop --require rubocop-minitest --require rubocop-performance + install: bin/fzf generate: @@ -184,4 +187,4 @@ update: $(GO) get -u $(GO) mod tidy -.PHONY: all generate build release test bench install clean docker docker-test update +.PHONY: all generate build release test bench lint install clean docker docker-test update diff --git a/test/test_go.rb b/test/test_go.rb index c328a226..ac294d62 100755 --- a/test/test_go.rb +++ b/test/test_go.rb @@ -3369,10 +3369,14 @@ class TestGoFZF < TestBase def test_boundary_match # Underscore boundaries should be ranked lower - assert_equal( - %w[[x] -x- -x_ _x- _x_], - `printf -- 'xxx\n-xx\nxx-\n_x_\n_x-\n-x_\n[x]\n-x-\n' | #{FZF} -f"'x'"`.lines(chomp: true) - ) + { + default: [' x '] + %w[/x/ [x] -x- -x_ _x- _x_], + path: ['/x/', ' x '] + %w[[x] -x- -x_ _x- _x_], + history: ['[x]', '-x-', ' x '] + %w[/x/ -x_ _x- _x_] + }.each do |scheme, expected| + result = `printf -- 'xxx\n-xx\nxx-\n_x_\n_x-\n-x_\n[x]\n-x-\n x \n/x/\n' | #{FZF} -f"'x'" --scheme=#{scheme}`.lines(chomp: true) + assert_equal expected, result + end end end