Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't skip acwrite buffers #188

Merged
merged 1 commit into from
Jun 20, 2022

Conversation

iamFIREcracker
Copy link
Contributor

Prior to this change, the editorconfig-vim will skip processing any
non-'normal' buffer, and the idea behind this is that we would not want
it to mess around with, say, 'help' or 'quickfix' buffers.

However, 'acwrite' buffers act pretty much like any other 'normal'
buffer, with custom filetypes and all; the only difference is that
'acwrite' buffers will always be writtein with BufWriteCmd autocommands
(see :h buftype).

Because of this, I have changed editorconfig-vim to skip processing
buffers which are not 'normal' (i.e., empty buftype), or 'acwrite'.

Prior to this change, the editorconfig-vim will skip processing any
non-'normal' buffer, and the idea behind this is that we would not want
it to mess around with, say, 'help' or 'quickfix' buffers.

However, 'acwrite' buffers act pretty much like any other 'normal'
buffer, with custom filetypes and all; the only difference is that
'acwrite' buffers will always be writtein with BufWriteCmd autocommands
(see `:h buftype`).

Because of this, I have changed editorconfig-vim to skip processing
buffers which are not 'normal' (i.e., empty buftype), or 'acwrite'.
@cxw42
Copy link
Member

cxw42 commented Feb 28, 2022

Thanks --- I had never heard of acwrite! Does it pass the plugin tests? CI currently only checks the core.

@cxw42 cxw42 added the Bug label Feb 28, 2022
@iamFIREcracker
Copy link
Contributor Author

I am not sure -- how do I run the plugin tests?

@cxw42
Copy link
Member

cxw42 commented Mar 6, 2022

@iamFIREcracker On a unix-like system, you should be able to do ./tests/travis-test.sh plugin from the top level of the repo. It requires Ruby and Bundler. If you have trouble, please let me know what OS/version/arch/... you're on and I'll see if I can find more specific instructions. Thanks!

@iamFIREcracker
Copy link
Contributor Author

@cxw42 sorry for the late reply -- you know, life...

I gave it a go this morning, but could not get it to work, so I am afraid I am going to need your help.

OS: macOS Big Sur/11.6.5

Output of rvm info (I don't do any ruby programming, but rvm is what I have been using when I occasionally needed a gem or something):

$ rvm info

ruby-3.1.2:

  system:
    uname:        "Darwin hairstyle.local 20.6.0 Darwin Kernel Version 20.6.0: Tue Feb 22 21:10:41 PST 2022; root:xnu-7195.141.26~1/RELEASE_X86_64 x86_64"
    name:         "OSX"
    version:      "11.6"
    architecture: "x86_64"
    bash:         "/usr/local/bin/bash => GNU bash, version 5.1.16(1)-release (x86_64-apple-darwin20.6.0)"
    zsh:          "/bin/zsh => zsh 5.8 (x86_64-apple-darwin20.0)"
    remote_path:  "osx/11.6/x86_64"
    xcode:        "13.2.1"

  rvm:
    version:      "1.29.12-next (master)"
    updated:      "16 minutes 1 second ago"
    path:         "/Users/matteolandi/.rvm"
    autolibs:     "[4] Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X)."

  ruby:
    interpreter:  "ruby"
    version:      "3.1.2p20"
    date:         "2022-04-12"
    platform:     "x86_64-darwin20"
    patchlevel:   "2022-04-12 revision 4491bb740a"
    full_version: "ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin20]"

  homes:
    gem:          "/Users/matteolandi/.rvm/gems/ruby-3.1.2"
    ruby:         "/Users/matteolandi/.rvm/rubies/ruby-3.1.2"

  binaries:
    ruby:         "/Users/matteolandi/.rvm/rubies/ruby-3.1.2/bin/ruby"
    irb:          "/Users/matteolandi/.rvm/rubies/ruby-3.1.2/bin/irb"
    gem:          "/Users/matteolandi/.rvm/rubies/ruby-3.1.2/bin/gem"
    rake:         "/Users/matteolandi/.rvm/rubies/ruby-3.1.2/bin/rake"

  environment:
    PATH:         "/Users/matteolandi/.rvm/gems/ruby-3.1.2/bin:/Users/matteolandi/.rvm/gems/ruby-3.1.2@global/bin:/Users/matteolandi/.rvm/rubies/ruby-3.1.2/bin:/Users/matteolandi/.rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/opt/X11/bin:/Applications/Wireshark.app/Contents/MacOS:/Users/matteolandi/bin:/Users/matteolandi/local/bin:/Library/Java/JavaVirtualMachines/openjdk-14.0.2.jdk/Contents/Home/bin:/usr/local/opt/ruby/bin:/usr/local/opt/python@3.9/bin:/usr/local/opt/curl/bin:/usr/local/sbin"
    GEM_HOME:     "/Users/matteolandi/.rvm/gems/ruby-3.1.2"
    GEM_PATH:     "/Users/matteolandi/.rvm/gems/ruby-3.1.2:/Users/matteolandi/.rvm/gems/ruby-3.1.2@global"
    MY_RUBY_HOME: "/Users/matteolandi/.rvm/rubies/ruby-3.1.2"
    IRBRC:        "/Users/matteolandi/.rvm/rubies/ruby-3.1.2/.irbrc"
    RUBYOPT:      ""
    gemset:       ""

Output of the test runner:

$ ./tests/travis-test.sh plugin

# Permit `travis-test.sh plugin` if TEST_WHICH is unset
if [[ ( ! "${TEST_WHICH:-}" ) && "${1:-}" ]]; then
    export TEST_WHICH="$1"
fi
+ [[ ! -n '' ]]
+ [[ -n plugin ]]
+ export TEST_WHICH=plugin
+ TEST_WHICH=plugin

if [[ ! "${TEST_WHICH:-}" ]]; then
    cat <<EOT
Usage: $0 \$WHICH
  or:  TEST_WHICH=\$WHICH $0
Run automated tests of editorconfig-vim

\$WHICH can be "core" or "plugin".
EOT
    exit 2
fi
+ [[ ! -n plugin ]]

if [[ "$TEST_WHICH" = 'plugin' ]]; then       # test plugin

    # If not running from Travis, do what Travis would have
    # done for us.
    if [[ ! "${BUNDLE_GEMFILE:-}" ]]; then
        here="$(cd "$(dirname "$0")" &>/dev/null ; pwd)"
        export BUNDLE_GEMFILE="${here}/plugin/Gemfile"
        # Install into tests/plugin/vendor.  Don't clear it first,
        # since you can clear it yourself if you're running from a
        # dev environment.
        bundle install --jobs=3 --retry=3 --deployment
    fi

    # Use the standalone Vimscript EditorConfig core to test the plugin's
    # external_command mode
    export EDITORCONFIG_VIM_EXTERNAL_CORE=tests/core/editorconfig

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

elif [[ "$TEST_WHICH" = 'core' ]]; then     # test core
    cd tests/core
    mkdir -p build  # May already exist if running from a dev env
    cd build
    cmake ..
    ctest . --output-on-failure -VV -C Debug
    # -C Debug: for Visual Studio builds, you have to specify
    # a configuration.

else
    echo 'Invalid TEST_WHICH value' 1>&2
    exit 1
fi
+ [[ plugin = \p\l\u\g\i\n ]]
+ [[ ! -n '' ]]
cd "$(dirname "$0")" &>/dev/null ; pwd
dirname "$0"
+++ dirname ./tests/travis-test.sh
++ cd ./tests
++ pwd
+ here=/Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests
+ export BUNDLE_GEMFILE=/Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/Gemfile
+ BUNDLE_GEMFILE=/Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/Gemfile
+ bundle install --jobs=3 --retry=3 --deployment
[DEPRECATED] The `--deployment` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set --local deployment 'true'`, and stop using this flag
Using rake 12.3.3
Using bundler 2.3.7
Using diff-lcs 1.2.5
Using rspec-support 3.4.1
Using rspec-core 3.4.1
Using rspec-expectations 3.4.0
Using rspec-mocks 3.4.0
Using rspec 3.4.0
Using vimrunner 0.3.1
Bundle complete! 3 Gemfile dependencies, 9 gems now installed.
Bundled gems are installed into `./tests/plugin/vendor/bundle`
+ export EDITORCONFIG_VIM_EXTERNAL_CORE=tests/core/editorconfig
+ EDITORCONFIG_VIM_EXTERNAL_CORE=tests/core/editorconfig
+ bundle exec rspec tests/plugin/spec/editorconfig_spec.rb
Testing default
bundler: failed to load command: rspec (/Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/bin/rspec)
/Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/gems/vimrunner-0.3.1/lib/vimrunner/platform.rb:25:in `vim': No suitable Vim executable could be found for this system. (Vimrunner::NoSuitableVimError)
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/gems/vimrunner-0.3.1/lib/vimrunner.rb:25:in `start'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb:4:in `create_vim'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb:135:in `block in <top (required)>'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/spec/editorconfig_spec.rb:137:in `<top (required)>'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1361:in `load'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1361:in `block in load_spec_files'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1359:in `each'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1359:in `load_spec_files'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:102:in `setup'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:88:in `run'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:73:in `run'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:41:in `invoke'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.4.1/exe/rspec:4:in `<top (required)>'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/bin/rspec:25:in `load'
        from /Users/matteolandi/my-env/dotfiles/.vim/pack/bundle/start/editorconfig-vim/tests/plugin/vendor/bundle/ruby/3.1.0/bin/rspec:25:in `<top (required)>'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `load'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli/exec.rb:58:in `kernel_load'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli/exec.rb:23:in `run'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli.rb:484:in `exec'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli.rb:31:in `dispatch'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/cli.rb:25:in `start'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:48:in `block in <top (required)>'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/3.1.0/bundler/friendly_errors.rb:103:in `with_friendly_errors'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.3.7/libexec/bundle:36:in `<top (required)>'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/bin/bundle:25:in `load'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/bin/bundle:25:in `<main>'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/bin/ruby_executable_hooks:22:in `eval'
        from /Users/matteolandi/.rvm/rubies/ruby-3.1.2/bin/ruby_executable_hooks:22:in `<main>'

Vim's --version:

$ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 30 2022 20:12:27)
macOS version - x86_64
Included patches: 1-4650
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     +perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
+clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           +python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          +ruby              +wildignore
+cursorbind        +lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      -sodium            -X11
+digraphs          +mouse             -sound             -xfontset
-dnd               -mouseshape        +spell             -xim
-ebcdic            +mouse_dec         +startuptime       -xpm
+emacs_tags        -mouse_gpm         +statusline        -xsmp
+eval              -mouse_jsbterm     -sun_workshop      -xterm_clipboard
+ex_extra          +mouse_netterm     +syntax            -xterm_save
+extra_search      +mouse_sgr         +tag_binary
-farsi             -mouse_sysmouse    -tag_old_static
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X -DMACOS_X_DARWIN -g -O2 -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/lib -o vim -lm -lncurses -liconv -lintl -framework AppKit -L/usr/local/opt/lua/lib -llua5.4 -mmacosx-version-min=11.3 -fstack-protector-strong -L/usr/local/lib -L/usr/local/Cellar/perl/5.34.0/lib/perl5/5.34.0/darwin-thread-multi-2level/CORE -lperl -L/usr/local/opt/python@3.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/config-3.10-darwin -lpython3.10 -framework CoreFoundation -lruby.3.1 -L/usr/local/Cellar/ruby/3.1.1/lib

@cxw42
Copy link
Member

cxw42 commented Jun 20, 2022

@iamFIREcracker thanks for giving it a try --- that is weird! I am not sure why you saw a failure. The only thing I noticed is that your commit is off master from a long time ago, and there have been some changes to travis-test since then. Anyway, all plugin tests passed on my machine! I also did some manual tests and they worked. ✔️

Log of my test run after cherry-picking this commit
~/proj/editorconfig-vim$ gitrecent
  === 2022-02-22 ===
* 9ac0138 01:56 ml  (HEAD -> foo) Don't skip acwrite buffers
|   === 2022-01-21 ===
*   a8e3e66 21:55 cw  (upstream/master, origin/master, origin/HEAD, master) Merge pull request #183 from cxw42/expect-improvement

~/proj/editorconfig-vim$ ./tests/travis-test.sh plugin

# Permit `travis-test.sh plugin` if TEST_WHICH is unset
if [[ ( ! "${TEST_WHICH:-}" ) && "${1:-}" ]]; then
    export TEST_WHICH="$1"
fi
+ [[ ! -n '' ]]
+ [[ -n plugin ]]
+ export TEST_WHICH=plugin
+ TEST_WHICH=plugin

if [[ ! "${TEST_WHICH:-}" ]]; then
    cat <<EOT
Usage: $0 \$WHICH
  or:  TEST_WHICH=\$WHICH $0
Run automated tests of editorconfig-vim

\$WHICH can be "core" or "plugin".
EOT
    exit 2
fi
+ [[ ! -n plugin ]]

if [[ "$TEST_WHICH" = 'plugin' ]]; then       # test plugin

    # If not running from Travis, do what Travis would have
    # done for us.
    if [[ ! "${BUNDLE_GEMFILE:-}" ]]; then
        here="$(cd "$(dirname "$0")" &>/dev/null ; pwd)"
        export BUNDLE_GEMFILE="${here}/plugin/Gemfile"
        # Install into tests/plugin/vendor.  Don't clear it first,
        # since you can clear it yourself if you're running from a
        # dev environment.
        bundle install --jobs=3 --retry=3 --deployment
    fi

    # Use the standalone Vimscript EditorConfig core to test the plugin's
    # external_command mode
    export EDITORCONFIG_VIM_EXTERNAL_CORE=tests/core/editorconfig

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

elif [[ "$TEST_WHICH" = 'core' ]]; then     # test core
    cd tests/core
    mkdir -p build  # May already exist if running from a dev env
    cd build
    cmake ..
    ctest . --output-on-failure -VV -C Debug
    # -C Debug: for Visual Studio builds, you have to specify
    # a configuration.

else
    echo 'Invalid TEST_WHICH value' 1>&2
    exit 1
fi
+ [[ plugin = \p\l\u\g\i\n ]]
+ [[ ! -n '' ]]
+++ dirname ./tests/travis-test.sh
++ cd ./tests
++ pwd
+ here=/home/cxw/proj/editorconfig-vim/tests
+ export BUNDLE_GEMFILE=/home/cxw/proj/editorconfig-vim/tests/plugin/Gemfile
+ BUNDLE_GEMFILE=/home/cxw/proj/editorconfig-vim/tests/plugin/Gemfile
+ bundle install --jobs=3 --retry=3 --deployment
[DEPRECATED] The `--deployment` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set deployment 'true'`, and stop using this flag                                                                                                                               
Using rake 12.3.3
Using bundler 2.1.4
Using diff-lcs 1.2.5
Using rspec-support 3.4.1
Using rspec-core 3.4.1
Using rspec-expectations 3.4.0
Using rspec-mocks 3.4.0
Using rspec 3.4.0
Using vimrunner 0.3.1
Bundle complete! 3 Gemfile dependencies, 9 gems now installed.
Bundled gems are installed into `./tests/plugin/vendor/bundle`
+ export EDITORCONFIG_VIM_EXTERNAL_CORE=tests/core/editorconfig
+ EDITORCONFIG_VIM_EXTERNAL_CORE=tests/core/editorconfig
+ bundle exec rspec tests/plugin/spec/editorconfig_spec.rb
Testing default
Testing with express vim_core mode
Testing with fallback to vim_core mode
Testing with external_command tests/core/editorconfig
................................................................

Finished in 4.92 seconds (files took 0.92531 seconds to load)
64 examples, 0 failures

@cxw42 cxw42 merged commit d354117 into editorconfig:master Jun 20, 2022
@iamFIREcracker
Copy link
Contributor Author

Hey, thanks lots for getting this merged. And yeah, I am not sure what was I thinking, when I decided to create a PR off of a very old version of master...my bad!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants