Skip to content

Commit 0818c7e

Browse files
authored
Merge pull request #140 from cxw42/test-from-cmdline
Can use tests/travis-test.sh to test plugin from command line
2 parents 8aff78a + 60b0655 commit 0818c7e

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
tags
22
tests/**/build
33
tests/**/.bundle
4+
5+
# Editor backup files
6+
*.swp
7+
*~
8+
~*

tests/plugin/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Where bundler installs local Gemfile dependencies
2+
/vendor/

tests/travis-test.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,42 @@
44
# Licensed Apache, version 2.0 or any later version, at your option.
55

66
# Error exit; debug output
7-
set -evx
7+
set -vxEeuo pipefail
8+
9+
# Permit `travis-test.sh plugin` if TEST_WHICH is unset
10+
if [[ ( ! "${TEST_WHICH:-}" ) && "${1:-}" ]]; then
11+
export TEST_WHICH="$1"
12+
fi
13+
14+
if [[ "$TEST_WHICH" = 'plugin' ]]; then # test plugin
15+
16+
# If not running from Travis, do what Travis would have
17+
# done for us.
18+
if [[ ! "${BUNDLE_GEMFILE:-}" ]]; then
19+
here="$(cd "$(dirname "$0")" &>/dev/null ; pwd)"
20+
export BUNDLE_GEMFILE="${here}/plugin/Gemfile"
21+
# Install into tests/plugin/vendor. Don't clear it first,
22+
# since you can clear it yourself if you're running from a
23+
# dev environment.
24+
bundle install --jobs=3 --retry=3 --deployment
25+
fi
826

9-
if [[ $TEST_WHICH = 'plugin' ]]; then # test plugin
1027
# Use the standalone Vimscript EditorConfig core to test the plugin's
1128
# external_command mode
1229
export EDITORCONFIG_VIM_EXTERNAL_CORE=tests/core/editorconfig
1330

1431
bundle exec rspec tests/plugin/spec/editorconfig_spec.rb
1532

16-
else # test core
33+
elif [[ "$TEST_WHICH" = 'core' ]]; then # test core
1734
cd tests/core
18-
mkdir build
35+
mkdir -p build # May already exist if running from a dev env
1936
cd build
2037
cmake ..
2138
ctest . --output-on-failure -VV -C Debug
2239
# -C Debug: for Visual Studio builds, you have to specify
2340
# a configuration.
41+
42+
else
43+
echo 'Invalid TEST_WHICH value' 1>&2
44+
exit 1
2445
fi

0 commit comments

Comments
 (0)