vim-flavor 2.2.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +12 -0
- data/.github/workflows/ci.yml +35 -0
- data/.ruby-version +1 -0
- data/README.md +126 -45
- data/Rakefile +11 -0
- data/config/cucumber.yml +1 -0
- data/features/.nav +2 -1
- data/features/backward_compatibilities/flavorfile.feature +166 -0
- data/features/backward_compatibilities/lockfile.feature +22 -0
- data/features/branches/changing_tracking_branches.feature +0 -3
- data/features/branches/detect_incompatible_declarations.feature +0 -2
- data/features/branches/install.feature +0 -2
- data/features/branches/update.feature +0 -1
- data/features/caching/deployment.feature +1 -0
- data/features/flavorfile/README.md +1 -1
- data/features/flavorfile/comments.feature +0 -1
- data/features/flavorfile/groups.feature +0 -3
- data/features/flavorfile/repository_name.feature +0 -3
- data/features/flavorfile/version_constraint.feature +3 -7
- data/features/install_vim_flavor.md +6 -12
- data/features/news.md +72 -0
- data/features/philosophy.md +4 -4
- data/features/resolve_dependencies/README.md +4 -3
- data/features/resolve_dependencies/basics.feature +0 -4
- data/features/resolve_dependencies/upgrade_outdated_dependencies.feature +0 -2
- data/features/resolve_dependencies/version_conflict.feature +0 -2
- data/features/step_definitions/cli_steps.rb +6 -1
- data/features/step_definitions/dependency_steps.rb +2 -1
- data/features/step_definitions/directory_steps.rb +1 -1
- data/features/step_definitions/file_steps.rb +2 -2
- data/features/step_definitions/flavor_steps.rb +25 -9
- data/features/step_definitions/flavorfile_steps.rb +10 -1
- data/features/step_definitions/lockfile_steps.rb +14 -5
- data/features/support/env.rb +22 -12
- data/features/testing_vim_plugins/README.md +7 -6
- data/features/testing_vim_plugins/dependencies.feature +2 -3
- data/features/testing_vim_plugins/failures.feature +3 -3
- data/features/testing_vim_plugins/specifying_test_scripts.feature +3 -3
- data/features/testing_vim_plugins/typical_usage.feature +30 -7
- data/features/typical_usage/README.md +7 -7
- data/features/typical_usage/deploy_to_arbitrary_place.feature +0 -1
- data/features/typical_usage/install_vim_plugins.feature +0 -1
- data/features/typical_usage/uninstall_vim_plugins.feature +0 -1
- data/features/typical_usage/update_vim_plugins.feature +0 -3
- data/features/uninstall_vim_flavor.md +3 -4
- data/features/version_lock.feature +0 -1
- data/features/version_tag_format.feature +0 -4
- data/lib/vim-flavor/cli.rb +2 -2
- data/lib/vim-flavor/console.rb +22 -0
- data/lib/vim-flavor/facade.rb +18 -49
- data/lib/vim-flavor/flavor.rb +2 -2
- data/lib/vim-flavor/flavorfile.rb +24 -1
- data/lib/vim-flavor/lockfile.rb +15 -0
- data/lib/vim-flavor/shellutility.rb +2 -1
- data/lib/vim-flavor/stringextension.rb +3 -11
- data/lib/vim-flavor/version.rb +1 -1
- data/lib/vim-flavor.rb +1 -1
- data/spec/branchversion_spec.rb +4 -4
- data/spec/stringextension_spec.rb +31 -0
- data/vim-flavor.gemspec +8 -5
- metadata +69 -26
- data/.travis.yml +0 -7
- data/features/step_definitions/bootstrap_script_steps.rb +0 -6
- data/spec/facade_spec.rb +0 -57
@@ -1,10 +1,10 @@
|
|
1
1
|
## Required softwares
|
2
2
|
|
3
|
-
* [Git](
|
4
|
-
* [Ruby](
|
5
|
-
* Recommendation: Use [
|
3
|
+
* [Git](https://git-scm.com/) 2.10.1 or later
|
4
|
+
* [Ruby](https://www.ruby-lang.org/) 3.0.0 or later
|
5
|
+
* Recommendation: Use [rbenv](https://github.com/rbenv/rbenv) or other tools
|
6
6
|
for ease of installation across different envinronments.
|
7
|
-
* [Vim](
|
7
|
+
* [Vim](https://www.vim.org/) 8.0 or later
|
8
8
|
* Note that Vim should be compiled as normal, big or huge version
|
9
9
|
to use most of plugins.
|
10
10
|
|
@@ -26,14 +26,8 @@
|
|
26
26
|
|
27
27
|
cd $YOUR_REPOSITORY_FOR_DOTFILES
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
# runtime flavors/bootstrap.vim
|
32
|
-
vim vimrc
|
33
|
-
|
34
|
-
touch VimFlavor VimFlavor.lock
|
35
|
-
|
36
|
-
git add VimFlavor VimFlavor.lock vimrc
|
29
|
+
touch Flavorfile Flavorfile.lock
|
30
|
+
git add Flavorfile Flavorfile.lock
|
37
31
|
git commit -m 'Use vim-flavor to manage my favorite Vim plugins'
|
38
32
|
|
39
33
|
|
data/features/news.md
CHANGED
@@ -1,3 +1,75 @@
|
|
1
|
+
## vim-flavor 4.0.0
|
2
|
+
|
3
|
+
### Incompatible changes
|
4
|
+
|
5
|
+
* Ruby 3.0 or later is required now.
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
## vim-flavor 3.0.0
|
11
|
+
|
12
|
+
### Enhancements
|
13
|
+
|
14
|
+
* Steps to start using vim-flavor are simplified. Especially, it is not
|
15
|
+
necessary to edit vimrc.
|
16
|
+
|
17
|
+
### Incompatible changes
|
18
|
+
|
19
|
+
* Vim 8.0 or later is required now.
|
20
|
+
* Deployment format is changed. It might be necessary to manually delete some
|
21
|
+
directories and files. See also the follwoing migration guide.
|
22
|
+
* The name of configuration file is changed.
|
23
|
+
* Old name is `VimFlavor`.
|
24
|
+
* New name is `Flavorfile`.
|
25
|
+
* Note that old name is still supported for backward compatibility. Old
|
26
|
+
name file is used if there is no new name file. But it is highly
|
27
|
+
recommended to rename.
|
28
|
+
* The name of lock file is changed.
|
29
|
+
* Old name is `VimFlavor.lock`.
|
30
|
+
* New name is `Flavorfile.lock`.
|
31
|
+
* To avoid unexpected result and confusion, vim-flavor stops its process as
|
32
|
+
soon as possible if old name lockfile exists.
|
33
|
+
|
34
|
+
### Migration guide from version 2
|
35
|
+
|
36
|
+
* Delete `~/.vim/flavors` directory.
|
37
|
+
* Delete `runtime flavors/bootstrap.vim` line from your vimrc.
|
38
|
+
* In your dotfiles repository:
|
39
|
+
* Rename `VimFlavor` as `Flavorfile`.
|
40
|
+
* Rename `VimFlavor.lock` as `Flavorfile.lock`.
|
41
|
+
* If you use vim-flavor for Vim plugin development, do the following steps in
|
42
|
+
that Vim plugin repository:
|
43
|
+
* Update `Gemfile` to uses vim-flavor 3.0 or later,
|
44
|
+
e.g., `gem 'vim-flavor', '~> 3.0'`.
|
45
|
+
* Rename `VimFlavor` as `Flavorfile`.
|
46
|
+
* Delete `.vim-flavor` directory. It is used to stash runtime dependencies to
|
47
|
+
run tests for your Vim plugin.
|
48
|
+
* Note that you must not commit `Flavorfile.lock` for your Vim plugin. It
|
49
|
+
makes your plugin hard to use with other plugins.
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
## vim-flavor 2.2.2
|
55
|
+
|
56
|
+
### Bug Fixes
|
57
|
+
|
58
|
+
* Fix `install`, `update` and `test` to work even if these commands are invoked
|
59
|
+
from non-bash shell.
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
## vim-flavor 2.2.1
|
65
|
+
|
66
|
+
### Bug Fixes
|
67
|
+
|
68
|
+
* Fix not to fail fetching repositories which have non-fastforward updates.
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
1
73
|
## vim-flavor 2.2.0
|
2
74
|
|
3
75
|
### Enhancements
|
data/features/philosophy.md
CHANGED
@@ -8,11 +8,11 @@ vim-flavor can install plugins which meet the following conditions:
|
|
8
8
|
This is an intentional design. Because:
|
9
9
|
* [vim-scripts.org](http://vim-scripts.org/) provides
|
10
10
|
[comprehensive Git mirrors](https://github.com/vim-scripts) for
|
11
|
-
[plugins uploaded to www.vim.org](
|
11
|
+
[plugins uploaded to www.vim.org](https://www.vim.org/scripts/index.php).
|
12
12
|
* Experimental plugins which are not uploaded to www.vim.org
|
13
13
|
are usually found in [GitHub](https://github.com/).
|
14
|
-
* Plugins must follow [
|
15
|
-
|
14
|
+
* Plugins must follow [Semantic Versioning
|
15
|
+
2.0.0](https://semver.org/spec/v2.0.0.html) and have "version"
|
16
16
|
tags in their repositories. For example, if there is the version 1.2.3 of
|
17
17
|
a plugin, its repository must have the tag `1.2.3`, and the files of the
|
18
18
|
version 1.2.3 can be checked out via the tag `1.2.3`. In other words,
|
@@ -35,7 +35,7 @@ vim-flavor can install plugins which meet the following conditions:
|
|
35
35
|
* Git mirrors by vim-scripts.org have proper directory structures even if
|
36
36
|
the original plugins are uploaded to www.vim.org without proper directory
|
37
37
|
structures. (A good example is
|
38
|
-
[a.vim](
|
38
|
+
[a.vim](https://www.vim.org/scripts/script.php?script_id=31) and
|
39
39
|
[its mirror](https://github.com/vim-scripts/a.vim).)
|
40
40
|
* Other Git repositories might not have proper directory structures.
|
41
41
|
Such plugins are not ready to use for everyone.
|
@@ -14,12 +14,13 @@ overlooked.
|
|
14
14
|
|
15
15
|
So that `vim-flavor` automatically resolves dependencies of Vim plugins. If
|
16
16
|
a plugin declares its dependencies as a [flavorfile](flavorfile) and saves it
|
17
|
-
as `
|
17
|
+
as `Flavorfile`, `vim-flavor` reads the file and automatically installs
|
18
18
|
dependencies according to the file.
|
19
19
|
|
20
20
|
`vim-flavor` also takes care about versions of Vim plugins. If two plugins
|
21
|
-
require the same plugin but required versions are not compatible to
|
22
|
-
installation will be stopped to avoid using Vim with a broken
|
21
|
+
require the same plugin but required versions are not compatible to each
|
22
|
+
other, installation will be stopped to avoid using Vim with a broken
|
23
|
+
configuration.
|
23
24
|
|
24
25
|
|
25
26
|
|
@@ -34,7 +34,6 @@ Feature: Resolve dependencies of Vim plugins
|
|
34
34
|
$foo_uri (1.1)
|
35
35
|
$qux_uri (2.1)
|
36
36
|
"""
|
37
|
-
And a bootstrap script is created in "$home/.vim"
|
38
37
|
And a flavor "$foo_uri" version "1.1" is deployed to "$home/.vim"
|
39
38
|
And a flavor "$bar_uri" version "2.1" is deployed to "$home/.vim"
|
40
39
|
And a flavor "$qux_uri" version "2.1" is deployed to "$home/.vim"
|
@@ -72,7 +71,6 @@ Feature: Resolve dependencies of Vim plugins
|
|
72
71
|
$foo_uri (1.1)
|
73
72
|
$qux_uri (1.1)
|
74
73
|
"""
|
75
|
-
And a bootstrap script is created in "$home/.vim"
|
76
74
|
And a flavor "$foo_uri" version "1.1" is deployed to "$home/.vim"
|
77
75
|
And a flavor "$bar_uri" version "2.1" is deployed to "$home/.vim"
|
78
76
|
And a flavor "$qux_uri" version "1.1" is deployed to "$home/.vim"
|
@@ -112,7 +110,6 @@ Feature: Resolve dependencies of Vim plugins
|
|
112
110
|
$foo_uri (2.1)
|
113
111
|
$qux_uri (2.1)
|
114
112
|
"""
|
115
|
-
And a bootstrap script is created in "$home/.vim"
|
116
113
|
And a flavor "$foo_uri" version "2.1" is deployed to "$home/.vim"
|
117
114
|
And a flavor "$bar_uri" version "2.1" is deployed to "$home/.vim"
|
118
115
|
And a flavor "$qux_uri" version "2.1" is deployed to "$home/.vim"
|
@@ -145,6 +142,5 @@ Feature: Resolve dependencies of Vim plugins
|
|
145
142
|
$bar_uri (2.1)
|
146
143
|
$foo_uri (2.1)
|
147
144
|
"""
|
148
|
-
And a bootstrap script is created in "$home/.vim"
|
149
145
|
And a flavor "$foo_uri" version "2.1" is deployed to "$home/.vim"
|
150
146
|
And a flavor "$bar_uri" version "2.1" is deployed to "$home/.vim"
|
@@ -40,7 +40,6 @@ Feature: Update outdated dependencies of Vim plugins
|
|
40
40
|
$B_uri (0.0)
|
41
41
|
$L_uri (0.4)
|
42
42
|
"""
|
43
|
-
And a bootstrap script is created in "$home/.vim"
|
44
43
|
And a flavor "$A_uri" version "0.0" is deployed to "$home/.vim"
|
45
44
|
And a flavor "$B_uri" version "0.0" is deployed to "$home/.vim"
|
46
45
|
And a flavor "$L_uri" version "0.4" is deployed to "$home/.vim"
|
@@ -81,7 +80,6 @@ Feature: Update outdated dependencies of Vim plugins
|
|
81
80
|
$L_uri (0.5)
|
82
81
|
$X_uri (0.0)
|
83
82
|
"""
|
84
|
-
And a bootstrap script is created in "$home/.vim"
|
85
83
|
And a flavor "$A_uri" version "0.0" is deployed to "$home/.vim"
|
86
84
|
And a flavor "$B_uri" version "0.0" is deployed to "$home/.vim"
|
87
85
|
And a flavor "$L_uri" version "0.5" is deployed to "$home/.vim"
|
@@ -31,7 +31,6 @@ Feature: Version conflict
|
|
31
31
|
$foo_uri ~> 2.0 is required by $qux_uri
|
32
32
|
Please resolve the conflict.
|
33
33
|
"""
|
34
|
-
And a bootstrap script is not created in "$home/.vim"
|
35
34
|
And a flavor "$foo_uri" is not deployed to "$home/.vim"
|
36
35
|
And a flavor "$bar_uri" is not deployed to "$home/.vim"
|
37
36
|
And a flavor "$qux_uri" is not deployed to "$home/.vim"
|
@@ -59,6 +58,5 @@ Feature: Version conflict
|
|
59
58
|
$foo_uri >= 2.0 is required by you
|
60
59
|
Please resolve the conflict.
|
61
60
|
"""
|
62
|
-
And a bootstrap script is not created in "$home/.vim"
|
63
61
|
And a flavor "$foo_uri" is not deployed to "$home/.vim"
|
64
62
|
And a flavor "$bar_uri" is not deployed to "$home/.vim"
|
@@ -7,7 +7,12 @@ Then 'it should pass' do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
Then /^it should (pass|fail) with template:$/ do |pass_fail, template|
|
10
|
-
|
10
|
+
expect(last_command_started).to have_output(an_output_string_including(expand(template)))
|
11
|
+
if pass_fail == 'pass'
|
12
|
+
expect(last_command_started).to be_successfully_executed
|
13
|
+
else
|
14
|
+
expect(last_command_started).not_to be_successfully_executed
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
18
|
When /^I run `(.*)` \(variables expanded\)$/ do |command|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
Then /^a dependency "(.*)" is stored in "(.*)"$/ do |repo_name, deps_path|
|
2
|
+
cache_path = "#{deps_path}/#{repo_name.zap}"
|
2
3
|
steps %Q{
|
3
|
-
Then a directory named "#{
|
4
|
+
Then a directory named "#{path_for_step(cache_path)}" should exist
|
4
5
|
}
|
5
6
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
Given /^an executable file named "(.*)" with:$/ do |file_path, content|
|
2
2
|
steps %Q{
|
3
|
-
Given a file named "#{file_path}" with:
|
3
|
+
Given a file named "#{path_for_step(file_path)}" with:
|
4
4
|
"""
|
5
5
|
#{content}
|
6
6
|
"""
|
7
7
|
}
|
8
|
-
File.chmod(0755, File.join([
|
8
|
+
File.chmod(0755, File.join([expand_path('.'), file_path]))
|
9
9
|
end
|
@@ -18,7 +18,11 @@ Given /^the repository "([^"]*)" has versions "([^"]*)"$/ do |basename, versions
|
|
18
18
|
end
|
19
19
|
|
20
20
|
Given /^the repository "([^"]*)" has versions "([^"]*)" and a flavorfile:$/ do |basename, versions, flavorfile_content|
|
21
|
-
add_new_versions_to_repo(basename, versions, flavorfile_content)
|
21
|
+
add_new_versions_to_repo(basename, versions, flavorfile_content, :new)
|
22
|
+
end
|
23
|
+
|
24
|
+
Given /^the repository "([^"]*)" has versions "([^"]*)" and an old name flavorfile:$/ do |basename, versions, flavorfile_content|
|
25
|
+
add_new_versions_to_repo(basename, versions, flavorfile_content, :old)
|
22
26
|
end
|
23
27
|
|
24
28
|
Given /^a (?:(?:GitHub|local) )?repository "([^"]*)" with versions "([^"]*)"$/ do |basename, versions|
|
@@ -38,6 +42,16 @@ Given /^a (?:(?:GitHub|local) )?repository "([^"]*)" with versions "([^"]*)" and
|
|
38
42
|
}
|
39
43
|
end
|
40
44
|
|
45
|
+
Given /^a (?:(?:GitHub|local) )?repository "([^"]*)" with versions "([^"]*)" and an old name flavorfile:$/ do |basename, versions, flavorfile_content|
|
46
|
+
steps %Q{
|
47
|
+
Given a repository "#{basename}"
|
48
|
+
And the repository "#{basename}" has versions "#{versions}" and an old name flavorfile:
|
49
|
+
"""
|
50
|
+
#{flavorfile_content}
|
51
|
+
"""
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
41
55
|
Given /^"([^"]*)" version "([^"]*)" is released$/ do |basename, version|
|
42
56
|
steps %Q{
|
43
57
|
Given the repository "#{basename}" has versions "#{version}"
|
@@ -58,21 +72,22 @@ Given /^a repository "([^"]*)" from offline cache$/ do |repo_name|
|
|
58
72
|
repository_path = make_repo_path(repo_name).sub(expand('$tmp/'), '')
|
59
73
|
sh <<-"END"
|
60
74
|
{
|
61
|
-
git clone --quiet --no-checkout 'vendor/#{repo_name}' '#{
|
75
|
+
git clone --quiet --no-checkout 'vendor/#{repo_name}' '#{expand_path('.')}/#{repository_path}'
|
62
76
|
} >/dev/null
|
63
77
|
END
|
64
78
|
end
|
65
79
|
|
66
80
|
Given /^I disable network to the original repository of "([^"]*)"$/ do |basename|
|
67
81
|
steps %Q{
|
68
|
-
Given I delete the directory "#{make_repo_path(basename)}"
|
82
|
+
Given I delete the directory "#{path_for_step(make_repo_path(basename))}"
|
69
83
|
}
|
70
84
|
end
|
71
85
|
|
72
86
|
When /^I create a file named "([^"]*)" in "([^"]*)" deployed to "([^"]*)"$/ do |file_name, v_repo_name, v_vimfiles_path|
|
73
87
|
flavor_path = make_flavor_path(expand(v_vimfiles_path), expand(v_repo_name))
|
88
|
+
file_path = "#{flavor_path}/#{file_name}"
|
74
89
|
steps %Q{
|
75
|
-
When I write to "#{
|
90
|
+
When I write to "#{path_for_step(file_path)}" with:
|
76
91
|
"""
|
77
92
|
"""
|
78
93
|
}
|
@@ -82,24 +97,24 @@ Then /^a flavor "([^"]*)" version "([^"]*)" is deployed to "([^"]*)"$/ do |v_rep
|
|
82
97
|
flavor_path = make_flavor_path(expand(v_vimfiles_path), expand(v_repo_name))
|
83
98
|
basename = expand(v_repo_name).split('/').last.sub(/^vim-/, '')
|
84
99
|
steps %Q{
|
85
|
-
Then the file "#{flavor_path}/doc/#{basename}.txt" should contain:
|
100
|
+
Then the file "#{path_for_step(flavor_path)}/doc/#{basename}.txt" should contain:
|
86
101
|
"""
|
87
102
|
*#{basename}* #{version}
|
88
103
|
"""
|
89
|
-
Then a file named "#{flavor_path}/doc/tags" should exist
|
104
|
+
Then a file named "#{path_for_step(flavor_path)}/doc/tags" should exist
|
90
105
|
}
|
91
106
|
end
|
92
107
|
|
93
108
|
Then /^a flavor "([^"]*)" is not deployed to "([^"]*)"$/ do |v_repo_name, v_vimfiles_path|
|
94
109
|
flavor_path = make_flavor_path(expand(v_vimfiles_path), expand(v_repo_name))
|
95
110
|
steps %Q{
|
96
|
-
Then a directory named "#{flavor_path}" should not exist
|
111
|
+
Then a directory named "#{path_for_step(flavor_path)}" should not exist
|
97
112
|
}
|
98
113
|
end
|
99
114
|
|
100
115
|
Then /^"([^"]*)" version "([^"]*)" is (?:(not) )?cached$/ do |v_repo_name, version, p|
|
101
116
|
d = make_cached_repo_path(expand(v_repo_name), expand('$home').to_stash_path)
|
102
|
-
(system <<-"END").
|
117
|
+
expect(system <<-"END").to equal(p != 'not')
|
103
118
|
{
|
104
119
|
cd '#{d}' &&
|
105
120
|
git rev-list --quiet '#{version}'
|
@@ -109,7 +124,8 @@ end
|
|
109
124
|
|
110
125
|
Then /^a file named "([^"]*)" (should(?: not)?) exist in "([^"]*)" deployed to "([^"]*)"$/ do |file_name, should, v_repo_name, v_vimfiles_path|
|
111
126
|
flavor_path = make_flavor_path(expand(v_vimfiles_path), expand(v_repo_name))
|
127
|
+
file_path = "#{flavor_path}/#{file_name}"
|
112
128
|
steps %Q{
|
113
|
-
Then a file named "#{
|
129
|
+
Then a file named "#{path_for_step(file_path)}" #{should} exist
|
114
130
|
}
|
115
131
|
end
|
@@ -1,6 +1,15 @@
|
|
1
1
|
Given 'a flavorfile with:' do |content|
|
2
2
|
steps %Q{
|
3
|
-
Given a file named "#{'.'.to_flavorfile_path}" with:
|
3
|
+
Given a file named "#{path_for_step(expand_path('.').to_flavorfile_path)}" with:
|
4
|
+
"""
|
5
|
+
#{expand(content)}
|
6
|
+
"""
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
Given 'an old name flavorfile with:' do |content|
|
11
|
+
steps %Q{
|
12
|
+
Given a file named "#{path_for_step("#{expand_path('.')}/VimFlavor")}" with:
|
4
13
|
"""
|
5
14
|
#{expand(content)}
|
6
15
|
"""
|
@@ -1,6 +1,15 @@
|
|
1
1
|
Given 'a lockfile with:' do |content|
|
2
2
|
steps %Q{
|
3
|
-
Given a file named "#{'.'.to_lockfile_path}" with:
|
3
|
+
Given a file named "#{path_for_step(expand_path('.').to_lockfile_path)}" with:
|
4
|
+
"""
|
5
|
+
#{expand(content)}
|
6
|
+
"""
|
7
|
+
}
|
8
|
+
end
|
9
|
+
|
10
|
+
Given 'an old name lockfile with:' do |content|
|
11
|
+
steps %Q{
|
12
|
+
Given a file named "#{path_for_step("#{expand_path('.')}/VimFlavor.lock")}" with:
|
4
13
|
"""
|
5
14
|
#{expand(content)}
|
6
15
|
"""
|
@@ -18,7 +27,7 @@ end
|
|
18
27
|
|
19
28
|
Given 'I delete the lockfile' do
|
20
29
|
steps %Q{
|
21
|
-
Given I remove the file "#{'.'.to_lockfile_path}"
|
30
|
+
Given I remove the file "#{path_for_step(expand_path('.').to_lockfile_path)}"
|
22
31
|
}
|
23
32
|
end
|
24
33
|
|
@@ -34,7 +43,7 @@ end
|
|
34
43
|
Then /^(?:a|the) lockfile is (?:created|updated) with:$/ do |content|
|
35
44
|
# For some reason, Cucumber drops the last newline from every docstring...
|
36
45
|
steps %Q{
|
37
|
-
Then the file "#{'.'.to_lockfile_path}" should contain exactly:
|
46
|
+
Then the file "#{path_for_step(expand_path('.').to_lockfile_path)}" should contain exactly:
|
38
47
|
"""
|
39
48
|
#{content == '' ? '' : expand(content) + "\n"}
|
40
49
|
"""
|
@@ -42,11 +51,11 @@ Then /^(?:a|the) lockfile is (?:created|updated) with:$/ do |content|
|
|
42
51
|
end
|
43
52
|
|
44
53
|
Then /^(?:a|the) lockfile is (?:created|updated) and matches with:$/ do |content|
|
45
|
-
|
54
|
+
expect(path_for_step(expand_path('.').to_lockfile_path)).to have_file_content(/#{content}/)
|
46
55
|
end
|
47
56
|
|
48
57
|
Then /^(?:a|the) lockfile is not created$/ do
|
49
58
|
steps %Q{
|
50
|
-
Then a file named "#{'.'.to_lockfile_path}" should not exist
|
59
|
+
Then a file named "#{path_for_step(expand_path('.').to_lockfile_path)}" should not exist
|
51
60
|
}
|
52
61
|
end
|
data/features/support/env.rb
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
require 'aruba/api'
|
2
2
|
require 'aruba/cucumber'
|
3
3
|
require 'fileutils'
|
4
|
+
require 'pathname'
|
4
5
|
require 'vim-flavor'
|
5
6
|
|
6
7
|
class FakeUserEnvironment
|
7
8
|
include Vim::Flavor::ShellUtility
|
8
9
|
|
9
|
-
def add_new_versions_to_repo(basename, versions, flavorfile_content = nil)
|
10
|
+
def add_new_versions_to_repo(basename, versions, flavorfile_content = nil, naming_style = :new)
|
10
11
|
repository_path = make_repo_path(basename)
|
12
|
+
flavorfile_path = naming_style == :new ?
|
13
|
+
repository_path.to_flavorfile_path :
|
14
|
+
"#{repository_path}/VimFlavor"
|
11
15
|
doc_name = basename.split('/').last.sub(/^vim-/, '')
|
12
16
|
sh <<-"END"
|
13
17
|
{
|
@@ -19,10 +23,10 @@ class FakeUserEnvironment
|
|
19
23
|
git add doc
|
20
24
|
#{
|
21
25
|
%Q{
|
22
|
-
cat <<'FF' >#{
|
26
|
+
cat <<'FF' >#{flavorfile_path}
|
23
27
|
#{expand(flavorfile_content)}
|
24
28
|
FF
|
25
|
-
git add #{
|
29
|
+
git add #{flavorfile_path}
|
26
30
|
} if flavorfile_content
|
27
31
|
}
|
28
32
|
git commit -m "Version $v"
|
@@ -44,6 +48,16 @@ FF
|
|
44
48
|
}
|
45
49
|
end
|
46
50
|
|
51
|
+
def path_for_step(path)
|
52
|
+
cwd = Pathname.new(expand_path('.'))
|
53
|
+
pathd = Pathname.new(path)
|
54
|
+
if not pathd.absolute?
|
55
|
+
pathd = cwd + pathd
|
56
|
+
end
|
57
|
+
|
58
|
+
pathd.relative_path_from(cwd).to_s
|
59
|
+
end
|
60
|
+
|
47
61
|
def make_cached_repo_path(repo_name, stash_path)
|
48
62
|
"#{stash_path}/repos/#{repo_name.zap}"
|
49
63
|
end
|
@@ -68,22 +82,18 @@ end
|
|
68
82
|
Before do
|
69
83
|
variable_table['version'] = Vim::Flavor::VERSION
|
70
84
|
|
71
|
-
variable_table['tmp'] = File.absolute_path(
|
85
|
+
variable_table['tmp'] = File.absolute_path(expand_path('.'))
|
72
86
|
|
73
87
|
steps %Q{
|
74
88
|
Given a directory named "home"
|
75
89
|
}
|
76
|
-
variable_table['home'] = File.absolute_path(File.join([
|
90
|
+
variable_table['home'] = File.absolute_path(File.join([expand_path('.'), 'home']))
|
77
91
|
|
78
92
|
@aruba_timeout_seconds = 5
|
79
|
-
end
|
80
93
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
set_env 'VIM_FLAVOR_GITHUB_URI_PREFIX', expand('file://$tmp/repos/')
|
85
|
-
set_env 'VIM_FLAVOR_GITHUB_URI_SUFFIX', ''
|
86
|
-
end
|
94
|
+
set_environment_variable 'VIM_FLAVOR_HOME', variable_table['home']
|
95
|
+
set_environment_variable 'VIM_FLAVOR_GITHUB_URI_PREFIX', expand('file://$tmp/repos/')
|
96
|
+
set_environment_variable 'VIM_FLAVOR_GITHUB_URI_SUFFIX', ''
|
87
97
|
end
|
88
98
|
|
89
99
|
World do
|
@@ -3,7 +3,7 @@
|
|
3
3
|
1. Write tests for your Vim plugin with
|
4
4
|
[vim-vspec](https://github.com/kana/vim-vspec).
|
5
5
|
2. Declare dependencies of your Vim plugin as a [flavorfile](flavorfile), and
|
6
|
-
save it as `
|
6
|
+
save it as `Flavorfile` in the root of your Vim plugin.
|
7
7
|
3. Run `vim-flavor test`.
|
8
8
|
|
9
9
|
|
@@ -14,15 +14,16 @@
|
|
14
14
|
It is hard to test Vim plugins, because there are a few problems:
|
15
15
|
|
16
16
|
* It is hard to write readable and maintainable test code in Vim script, even
|
17
|
-
for skilled users. Because Vim script is not expressive as script
|
18
|
-
like Ruby
|
17
|
+
for skilled users. Because Vim script is not expressive as other script
|
18
|
+
languages like Ruby.
|
19
19
|
* Each test must be run in an isolated environment to guarantee the same
|
20
20
|
results for every time and everywhere. So that all settings including vimrc
|
21
|
-
and plugins must be ignored.
|
22
|
-
|
21
|
+
and plugins of yours must be ignored. Your viminfo also must not be read
|
22
|
+
and written to avoid unexpected test failures and unexpectedly overwritten
|
23
|
+
of registers and marks you used.
|
23
24
|
* Some plugins require other plugins at runtime. Such dependencies must be
|
24
25
|
resolved, but they must be installed into a temporary place to avoid
|
25
|
-
corrupting
|
26
|
+
corrupting your environment. And `'runtimepath'` must be configured
|
26
27
|
carefully for both dependencies and plugins under development.
|
27
28
|
|
28
29
|
Therefore it is hard to do right testing for Vim plugins from scratch. As
|
@@ -53,8 +53,8 @@ Feature: Dependencies
|
|
53
53
|
kana/vim-textobj-user \(0\.\d+(\.\d+)?\)
|
54
54
|
kana/vim-vspec \(1\.\d+(\.\d+)?\)
|
55
55
|
"""
|
56
|
-
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/
|
57
|
-
And a dependency "kana/vim-textobj-user" is stored in ".vim-flavor/
|
56
|
+
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/pack/flavors/start"
|
57
|
+
And a dependency "kana/vim-textobj-user" is stored in ".vim-flavor/pack/flavors/start"
|
58
58
|
|
59
59
|
Scenario: Update dependencies for testing
|
60
60
|
Given a flavorfile with:
|
@@ -89,7 +89,6 @@ Feature: Dependencies
|
|
89
89
|
When I run `vim-flavor test --update-dependencies`
|
90
90
|
Then it should pass with regexp:
|
91
91
|
"""
|
92
|
-
.*
|
93
92
|
-------- Preparing dependencies
|
94
93
|
Checking versions...
|
95
94
|
Use kana/vim-textobj-user ... 0\.3\.13
|
@@ -36,7 +36,7 @@ Feature: Failures
|
|
36
36
|
-------- Testing a Vim plugin
|
37
37
|
t/basics.vim ..\s
|
38
38
|
not ok 1 - g:foo is equal to 5
|
39
|
-
# Expected g:foo == 5
|
39
|
+
# Expected g:foo == 5 at line 1
|
40
40
|
# Actual value: 3
|
41
41
|
# Expected value: 5
|
42
42
|
Failed 1/1 subtests
|
@@ -45,7 +45,7 @@ Feature: Failures
|
|
45
45
|
-------------------
|
46
46
|
t/basics.vim \(Wstat: 0 Tests: 1 Failed: 1\)
|
47
47
|
Failed test: 1
|
48
|
-
Files=1, Tests=1,
|
48
|
+
Files=1, Tests=1, \d+ wallclock secs .*
|
49
49
|
Result: FAIL
|
50
50
|
"""
|
51
51
|
And the output should not contain:
|
@@ -56,4 +56,4 @@ Feature: Failures
|
|
56
56
|
"""
|
57
57
|
kana/vim-vspec \(1\.\d+(\.\d+)?\)
|
58
58
|
"""
|
59
|
-
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/
|
59
|
+
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/pack/flavors/start"
|
@@ -52,7 +52,7 @@ Feature: Specifying test scripts
|
|
52
52
|
"""
|
53
53
|
kana/vim-vspec \(1\.\d+(\.\d+)?\)
|
54
54
|
"""
|
55
|
-
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/
|
55
|
+
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/pack/flavors/start"
|
56
56
|
|
57
57
|
Scenario: Running a specific `.vim` test script
|
58
58
|
When I run `vim-flavor test spec/basics.vim`
|
@@ -74,7 +74,7 @@ Feature: Specifying test scripts
|
|
74
74
|
"""
|
75
75
|
kana/vim-vspec \(1\.\d+(\.\d+)?\)
|
76
76
|
"""
|
77
|
-
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/
|
77
|
+
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/pack/flavors/start"
|
78
78
|
|
79
79
|
Scenario: Running a specific `.t` test script
|
80
80
|
When I run `vim-flavor test spec/sh.t`
|
@@ -96,4 +96,4 @@ Feature: Specifying test scripts
|
|
96
96
|
"""
|
97
97
|
kana/vim-vspec \(1\.\d+(\.\d+)?\)
|
98
98
|
"""
|
99
|
-
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/
|
99
|
+
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/pack/flavors/start"
|
@@ -5,12 +5,6 @@ Feature: Typical usage
|
|
5
5
|
|
6
6
|
Background:
|
7
7
|
Given a repository "kana/vim-vspec" from offline cache
|
8
|
-
|
9
|
-
Scenario: Testing a Vim plugin without any dependency
|
10
|
-
Given a flavorfile with:
|
11
|
-
"""ruby
|
12
|
-
# No dependency
|
13
|
-
"""
|
14
8
|
And a file named "plugin/foo.vim" with:
|
15
9
|
"""vim
|
16
10
|
let g:foo = 3
|
@@ -33,6 +27,35 @@ Feature: Typical usage
|
|
33
27
|
echo 'ok 1'
|
34
28
|
echo '1..1'
|
35
29
|
"""
|
30
|
+
|
31
|
+
Scenario: Testing a Vim plugin with no dependencies
|
32
|
+
Given a flavorfile with:
|
33
|
+
"""ruby
|
34
|
+
# No dependencies
|
35
|
+
"""
|
36
|
+
When I run `vim-flavor test`
|
37
|
+
Then it should pass with regexp:
|
38
|
+
"""
|
39
|
+
-------- Preparing dependencies
|
40
|
+
Checking versions...
|
41
|
+
Use kana/vim-vspec ... 1\.\d+(\.\d+)?
|
42
|
+
Deploying plugins...
|
43
|
+
kana/vim-vspec 1\.\d+(\.\d+)? ... done
|
44
|
+
Completed.
|
45
|
+
-------- Testing a Vim plugin
|
46
|
+
t/basics.vim .. ok
|
47
|
+
t/sh.t ........ ok
|
48
|
+
All tests successful.
|
49
|
+
Files=2, Tests=2, \d+ wallclock secs .*
|
50
|
+
Result: PASS
|
51
|
+
"""
|
52
|
+
And a lockfile is created and matches with:
|
53
|
+
"""
|
54
|
+
kana/vim-vspec \(1\.\d+(\.\d+)?\)
|
55
|
+
"""
|
56
|
+
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/pack/flavors/start"
|
57
|
+
|
58
|
+
Scenario: Assuming no dependencies if flavorfile does not exist
|
36
59
|
When I run `vim-flavor test`
|
37
60
|
Then it should pass with regexp:
|
38
61
|
"""
|
@@ -53,4 +76,4 @@ Feature: Typical usage
|
|
53
76
|
"""
|
54
77
|
kana/vim-vspec \(1\.\d+(\.\d+)?\)
|
55
78
|
"""
|
56
|
-
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/
|
79
|
+
And a dependency "kana/vim-vspec" is stored in ".vim-flavor/pack/flavors/start"
|