Update to Command-T 5.0.3.

Resolves: rhbz#1631111
This commit is contained in:
Vít Ondruch 2021-03-04 20:48:16 +01:00
commit beda3c5329
5 changed files with 322 additions and 4 deletions

1
.gitignore vendored
View file

@ -8,3 +8,4 @@
/command-t-3.0.2.zip
/command-t-4.0.tar.gz
/command-t-5.0.2.tar.gz
/command-t-5.0.3.tar.gz

View file

@ -1 +1 @@
SHA512 (command-t-5.0.2.tar.gz) = f8c8356231c3fb0f3a91cb61f534acac4dd401721a940c6ea045ada287d29395923eb46b1cb4f55b8254000f10eea9970841531abb2b110992180a1edbd66b81
SHA512 (command-t-5.0.3.tar.gz) = 588ee1516039e6cd45210de43307c02259fed29cc7610c222fe705cdf1d5938f51f823d41b546a36320da31db12e902363867da91b18fe56ea09c1efe2bb51fb

View file

@ -0,0 +1,243 @@
From a185ccc2f4483f01edd80432b3daebdebdb15a7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
Date: Thu, 4 Mar 2021 13:53:36 +0100
Subject: [PATCH] Use rspec-mock for stubbing.
This allows to remove `rr` dependency and therefore reduce dependency
chain.
---
spec/command-t/controller_spec.rb | 72 +++++++++----------
spec/command-t/finder/buffer_finder_spec.rb | 2 +-
spec/command-t/finder/file_finder_spec.rb | 6 +-
spec/command-t/scanner/buffer_scanner_spec.rb | 6 +-
.../file_scanner/ruby_file_scanner_spec.rb | 8 +--
.../watchman_file_scanner_spec.rb | 6 +-
spec/spec_helper.rb | 4 --
7 files changed, 49 insertions(+), 55 deletions(-)
diff --git a/spec/command-t/controller_spec.rb b/spec/command-t/controller_spec.rb
index 3a3fcaf..6bbd6d7 100644
--- a/spec/command-t/controller_spec.rb
+++ b/spec/command-t/controller_spec.rb
@@ -16,35 +16,35 @@ describe CommandT::Controller do
end
def set_string(name, value)
- stub(::VIM).evaluate(%{exists("#{name}")}).returns(1)
- stub(::VIM).evaluate(name).returns(value)
+ allow(::VIM).to receive(:evaluate).with(%{exists("#{name}")}).and_return(1)
+ allow(::VIM).to receive(:evaluate).with(name).and_return(value)
end
it 'opens relative paths inside the working directory' do
- stub(::VIM).evaluate('a:arg').returns('')
+ allow(::VIM).to receive(:evaluate).with('a:arg').and_return('')
set_string('g:CommandTTraverseSCM', 'pwd')
controller.show_file_finder
- mock(::VIM).command('silent CommandTOpen edit path/to/selection')
+ expect(::VIM).to receive(:command).with('silent CommandTOpen edit path/to/selection')
controller.accept_selection
end
it 'opens absolute paths outside the working directory' do
- stub(::VIM).evaluate('a:arg').returns('../outside')
+ allow(::VIM).to receive(:evaluate).with('a:arg').and_return('../outside')
controller.show_file_finder
- mock(::VIM).command('silent CommandTOpen edit /working/outside/path/to/selection')
+ expect(::VIM).to receive(:command).with('silent CommandTOpen edit /working/outside/path/to/selection')
controller.accept_selection
end
it 'does not get confused by common directory prefixes' do
- stub(::VIM).evaluate('a:arg').returns('../directory-oops')
+ allow(::VIM).to receive(:evaluate).with('a:arg').and_return('../directory-oops')
controller.show_file_finder
- mock(::VIM).command('silent CommandTOpen edit /working/directory-oops/path/to/selection')
+ expect(::VIM).to receive(:command).with('silent CommandTOpen edit /working/directory-oops/path/to/selection')
controller.accept_selection
end
it 'does not enter an infinite loop when toggling focus' do
# https://github.com/wincent/command-t/issues/157
- stub(::VIM).evaluate('a:arg').returns('')
+ allow(::VIM).to receive(:evaluate).with('a:arg').and_return('')
set_string('g:CommandTTraverseSCM', 'pwd')
controller.show_file_finder
expect { controller.toggle_focus }.to_not raise_error
@@ -59,43 +59,43 @@ describe CommandT::Controller do
def stub_finder(sorted_matches=[])
finder = CommandT::Finder::FileFinder.new
- stub(finder).path = anything
- stub(finder).sorted_matches_for(anything, anything).returns(sorted_matches)
- stub(CommandT::Finder::FileFinder).new.returns(finder)
+ allow(finder).to receive(:"path=").with(anything)
+ allow(finder).to receive(:sorted_matches_for).with(anything, anything).and_return(sorted_matches)
+ allow(CommandT::Finder::FileFinder).to receive(:new).and_return(finder)
end
def stub_match_window(selection)
match_window = Object.new
- stub(match_window).matches = anything
- stub(match_window).leave
- stub(match_window).focus
- stub(match_window).selection.returns(selection)
- stub(CommandT::MatchWindow).new.returns(match_window)
+ allow(match_window).to receive(:"matches=").with(anything)
+ allow(match_window).to receive(:leave)
+ allow(match_window).to receive(:focus)
+ allow(match_window).to receive(:selection).and_return(selection)
+ allow(CommandT::MatchWindow).to receive(:new).and_return(match_window)
end
def stub_prompt(abbrev='')
prompt = Object.new
- stub(prompt).focus
- stub(prompt).unfocus
- stub(prompt).clear!
- stub(prompt).redraw
- stub(prompt).abbrev.returns(abbrev)
- stub(CommandT::Prompt).new.returns(prompt)
+ allow(prompt).to receive(:focus)
+ allow(prompt).to receive(:unfocus)
+ allow(prompt).to receive(:clear!)
+ allow(prompt).to receive(:redraw)
+ allow(prompt).to receive(:abbrev).and_return(abbrev)
+ allow(CommandT::Prompt).to receive(:new).and_return(prompt)
end
def stub_vim(working_directory)
- stub($curbuf).number.returns('0')
- stub(::VIM).command(/noremap/)
- stub(::VIM).command('silent b 0')
- stub(::VIM).command(/augroup/)
- stub(::VIM).command('au!')
- stub(::VIM).command(/autocmd/)
- stub(::VIM).evaluate(/exists\(.+\)/).returns('0')
- stub(::VIM).evaluate('getcwd()').returns(working_directory)
- stub(::VIM).evaluate('&buflisted').returns('1')
- stub(::VIM).evaluate('&lines').returns('80')
- stub(::VIM).evaluate('&term').returns('vt100')
- stub(::VIM).evaluate('v:version').returns(704)
- stub(::VIM).evaluate('!&buflisted && &buftype == "nofile"')
+ allow($curbuf).to receive(:number).and_return('0')
+ allow(::VIM).to receive(:command).with(/noremap/)
+ allow(::VIM).to receive(:command).with('silent b 0')
+ allow(::VIM).to receive(:command).with(/augroup/)
+ allow(::VIM).to receive(:command).with('au!')
+ allow(::VIM).to receive(:command).with(/autocmd/)
+ allow(::VIM).to receive(:evaluate).with(/exists\(.+\)/).and_return('0')
+ allow(::VIM).to receive(:evaluate).with('getcwd()').and_return(working_directory)
+ allow(::VIM).to receive(:evaluate).with('&buflisted').and_return('1')
+ allow(::VIM).to receive(:evaluate).with('&lines').and_return('80')
+ allow(::VIM).to receive(:evaluate).with('&term').and_return('vt100')
+ allow(::VIM).to receive(:evaluate).with('v:version').and_return(704)
+ allow(::VIM).to receive(:evaluate).with('!&buflisted && &buftype == "nofile"')
end
end
diff --git a/spec/command-t/finder/buffer_finder_spec.rb b/spec/command-t/finder/buffer_finder_spec.rb
index f0df4e1..be56463 100644
--- a/spec/command-t/finder/buffer_finder_spec.rb
+++ b/spec/command-t/finder/buffer_finder_spec.rb
@@ -6,7 +6,7 @@ require 'spec_helper'
describe CommandT::Finder::BufferFinder do
before do
@paths = %w(.git/config .vim/notes .vimrc baz foo/beta)
- any_instance_of(CommandT::Scanner::BufferScanner, :paths => @paths)
+ allow_any_instance_of(CommandT::Scanner::BufferScanner).to receive(:paths).and_return(@paths)
@finder = CommandT::Finder::BufferFinder.new
end
diff --git a/spec/command-t/finder/file_finder_spec.rb b/spec/command-t/finder/file_finder_spec.rb
index cac5388..9654105 100644
--- a/spec/command-t/finder/file_finder_spec.rb
+++ b/spec/command-t/finder/file_finder_spec.rb
@@ -19,9 +19,9 @@ describe CommandT::Finder::FileFinder do
end
before do
- stub(::VIM).evaluate(/expand/) { 0 }
- stub(::VIM).command(/echon/)
- stub(::VIM).command('redraw')
+ allow(::VIM).to receive(:evaluate).with(/expand/) { 0 }
+ allow(::VIM).to receive(:command).with(/echon/)
+ allow(::VIM).to receive(:command).with('redraw')
end
describe 'sorted_matches_for method' do
diff --git a/spec/command-t/scanner/buffer_scanner_spec.rb b/spec/command-t/scanner/buffer_scanner_spec.rb
index acc3b7e..a4ade60 100644
--- a/spec/command-t/scanner/buffer_scanner_spec.rb
+++ b/spec/command-t/scanner/buffer_scanner_spec.rb
@@ -14,10 +14,10 @@ describe CommandT::Scanner::BufferScanner do
before do
@paths = %w(bar/abc bar/xyz baz bing foo/alpha/t1 foo/alpha/t2 foo/beta)
@scanner = CommandT::Scanner::BufferScanner.new
- stub(@scanner).relative_path_under_working_directory(is_a(String)) { |arg| arg }
- stub(::VIM::Buffer).count { 7 }
+ allow(@scanner).to receive(:relative_path_under_working_directory).with(kind_of(String)) { |arg| arg }
+ allow(::VIM::Buffer).to receive(:count) { 7 }
(0..6).each do |n|
- stub(::VIM::Buffer)[n].returns(buffer @paths[n])
+ allow(::VIM::Buffer).to receive(:'[]').with(n).and_return(buffer @paths[n])
end
end
diff --git a/spec/command-t/scanner/file_scanner/ruby_file_scanner_spec.rb b/spec/command-t/scanner/file_scanner/ruby_file_scanner_spec.rb
index 10f0e22..3d60c2e 100644
--- a/spec/command-t/scanner/file_scanner/ruby_file_scanner_spec.rb
+++ b/spec/command-t/scanner/file_scanner/ruby_file_scanner_spec.rb
@@ -11,10 +11,10 @@ describe CommandT::Scanner::FileScanner::RubyFileScanner do
)
@scanner = CommandT::Scanner::FileScanner::RubyFileScanner.new(@dir)
- stub(::VIM).evaluate(/exists/) { 1 }
- stub(::VIM).evaluate(/expand\(.+\)/) { '0' }
- stub(::VIM).command(/echon/)
- stub(::VIM).command('redraw')
+ allow(::VIM).to receive(:evaluate).with(/exists/) { 1 }
+ allow(::VIM).to receive(:evaluate).with(/expand\(.+\)/) { '0' }
+ allow(::VIM).to receive(:command).with(/echon/)
+ allow(::VIM).to receive(:command).with('redraw')
end
describe 'paths method' do
diff --git a/spec/command-t/scanner/file_scanner/watchman_file_scanner_spec.rb b/spec/command-t/scanner/file_scanner/watchman_file_scanner_spec.rb
index f6ec70d..ffad09e 100644
--- a/spec/command-t/scanner/file_scanner/watchman_file_scanner_spec.rb
+++ b/spec/command-t/scanner/file_scanner/watchman_file_scanner_spec.rb
@@ -8,14 +8,12 @@ describe CommandT::Scanner::FileScanner::WatchmanFileScanner do
it 'falls back to the FindFileScanner' do
# fake an error
scanner = described_class.new
- stub(scanner).get_raw_sockname do
+ allow(scanner).to receive(:get_raw_sockname) do
raise described_class::WatchmanError
end
# expect call on superclass
- any_instance_of(CommandT::Scanner::FileScanner::FindFileScanner) do |klass|
- mock(klass).paths!
- end
+ expect_any_instance_of(CommandT::Scanner::FileScanner::FindFileScanner).to receive(:paths!)
scanner.paths!
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 2775956..370d46c 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -16,10 +16,6 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'command-t'
require 'command-t/ext'
-RSpec.configure do |config|
- config.mock_framework = :rr
-end
-
# Fake top-level VIM implementation, for stubbing.
module VIM
class << self
--
2.30.0

View file

@ -0,0 +1,63 @@
From 52adb808e2db85035e9a5a214cb147280c2f10e0 Mon Sep 17 00:00:00 2001
From: Greg Hurrell <greg.hurrell@liferay.com>
Date: Thu, 4 Mar 2021 19:20:43 +0100
Subject: [PATCH] test: fix tests
These are all probably very sensitive to environment (Ruby version etc),
and I haven't run them for a while, so just doing a duct-tape and
chicken-wire kind of fix to get everything green on my system.
Note that I "defanged" the BufferScanner tests which were failing and
were too complicated (too many mocks, so it is hard to be sure that they
verified anything at all) by effectively turning them into a
blinking-light demo that doesn't really do much.
With these changes:
Finished in 0.10298 seconds (files took 0.11239 seconds to load)
121 examples, 0 failures, 1 pending
---
spec/command-t/controller_spec.rb | 3 +++
spec/command-t/scanner/buffer_scanner_spec.rb | 12 +-----------
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/spec/command-t/controller_spec.rb b/spec/command-t/controller_spec.rb
index 6bbd6d78..70751c82 100644
--- a/spec/command-t/controller_spec.rb
+++ b/spec/command-t/controller_spec.rb
@@ -95,6 +95,9 @@ def stub_vim(working_directory)
allow(::VIM).to receive(:evaluate).with('&buflisted').and_return('1')
allow(::VIM).to receive(:evaluate).with('&lines').and_return('80')
allow(::VIM).to receive(:evaluate).with('&term').and_return('vt100')
+ allow(::VIM).to receive(:evaluate).with("fnameescape('#{working_directory}-oops/path/to/selection')").and_return("#{working_directory}-oops/path/to/selection")
+ allow(::VIM).to receive(:evaluate).with("fnameescape('path/to/selection')").and_return('path/to/selection')
+ allow(::VIM).to receive(:evaluate).with("fnameescape('/working/outside/path/to/selection')").and_return('/working/outside/path/to/selection')
allow(::VIM).to receive(:evaluate).with('v:version').and_return(704)
allow(::VIM).to receive(:evaluate).with('!&buflisted && &buftype == "nofile"')
end
diff --git a/spec/command-t/scanner/buffer_scanner_spec.rb b/spec/command-t/scanner/buffer_scanner_spec.rb
index a4ade60c..d8a014a8 100644
--- a/spec/command-t/scanner/buffer_scanner_spec.rb
+++ b/spec/command-t/scanner/buffer_scanner_spec.rb
@@ -5,20 +5,10 @@
require 'ostruct'
describe CommandT::Scanner::BufferScanner do
- def buffer(name)
- b = OpenStruct.new
- b.name = name
- b
- end
-
before do
@paths = %w(bar/abc bar/xyz baz bing foo/alpha/t1 foo/alpha/t2 foo/beta)
@scanner = CommandT::Scanner::BufferScanner.new
- allow(@scanner).to receive(:relative_path_under_working_directory).with(kind_of(String)) { |arg| arg }
- allow(::VIM::Buffer).to receive(:count) { 7 }
- (0..6).each do |n|
- allow(::VIM::Buffer).to receive(:'[]').with(n).and_return(buffer @paths[n])
- end
+ allow(@scanner).to receive(:paths!).and_return(@paths)
end
describe 'paths method' do

View file

@ -3,8 +3,8 @@
%global appdata_dir %{_datadir}/appdata
Name: vim-command-t
Version: 5.0.2
Release: 13%{?dist}
Version: 5.0.3
Release: 1%{?dist}
Summary: An extremely fast, intuitive mechanism for opening files in VIM
License: BSD
URL: https://github.com/wincent/command-t
@ -12,6 +12,12 @@ Source0: https://github.com/wincent/command-t/archive/%{version}/command-t-%{ver
# Relax the Command-T version checking.
# https://github.com/wincent/command-t/issues/192
Patch0: vim-3.0.2-Check-RUBY_LIB_VERSION-instead-of-RUBY_VERSION.patch
# Use rspec-mock for stubbing to fix the build failures with RR 1.2+.
# https://github.com/wincent/command-t/pull/375
Patch1: vim-command-t-5.0.3-Use-rspec-mock-for-stubbing.patch
# Fix `CommandT::Scanner::BufferScanner` test.
# https://github.com/wincent/command-t/commit/52adb808e2db85035e9a5a214cb147280c2f10e0
Patch2: vim-command-t-5.0.3-fix-tests.patch
Requires: ruby(release)
# Although command-t does not depend on rubygems directly, the RubyGems are
# required by Ruby, but not always (rhbz#845011). So it is necessary to enforce
@ -25,7 +31,6 @@ BuildRequires: ruby(release)
BuildRequires: ruby-devel
BuildRequires: rubygems
BuildRequires: rubygem(rspec) >= 3
BuildRequires: rubygem(rr)
BuildRequires: gcc
# Defines %%vimfiles_root
BuildRequires: vim-filesystem
@ -45,6 +50,8 @@ more weight.
%setup -q -n command-t-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%build
pushd ./ruby/command-t/ext/command-t
@ -96,6 +103,10 @@ rspec -Iruby spec
%changelog
* Thu Mar 04 2021 Vít Ondruch <vondruch@redhat.com> - 5.0.3-1
- Update to Command-T 5.0.3.
Resolves: rhbz#1631111
* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 5.0.2-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild