mirror of
https://github.com/amix/vimrc
synced 2025-07-01 12:45:00 +08:00
feat: include editorconfig-vim plugin
Signed-off-by: luc <onion0709@gmail.com>
This commit is contained in:
@ -0,0 +1,53 @@
|
||||
# CMakeLists.txt for core testing in
|
||||
# editorconfig-core-vimscript and editorconfig-vim.
|
||||
|
||||
# Copyright (c) 2011-2019 EditorConfig Team
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# To perform the test, from the root of the project tree, run
|
||||
# mkdir build
|
||||
# cd build
|
||||
# cmake ..
|
||||
# ctest .
|
||||
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
#set(CMAKE_LEGACY_CYGWIN_WIN32 0)
|
||||
|
||||
# Do not check any compiler
|
||||
project(editorconfig-core-vimscript NONE)
|
||||
|
||||
enable_testing()
|
||||
|
||||
# The test executable to use
|
||||
if(NOT WIN32)
|
||||
set(EDITORCONFIG_CMD "${CMAKE_SOURCE_DIR}/editorconfig")
|
||||
else()
|
||||
set(EDITORCONFIG_CMD "${CMAKE_SOURCE_DIR}/editorconfig.bat")
|
||||
endif()
|
||||
set(EDITORCONFIG_CMD_IS_TARGET FALSE)
|
||||
|
||||
add_subdirectory(tests)
|
||||
|
||||
# CTestCustom.cmake contains platform-specific test configuration.
|
||||
configure_file(CTestCustom.cmake ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
|
@ -0,0 +1,34 @@
|
||||
# CTestCustom.cmake: Skip UTF-8 tests
|
||||
# Part of editorconfig-vim
|
||||
|
||||
# Copyright (c) 2011-2019 EditorConfig Team
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# Skip UTF8 tests on Windows for now per
|
||||
# https://github.com/editorconfig/editorconfig-core-c/pull/31#issue-154810185
|
||||
if(WIN32 AND (NOT "$ENV{RUN_UTF8}"))
|
||||
message(WARNING "Skipping UTF-8 tests on this platform")
|
||||
set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} g_utf_8_char)
|
||||
set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} utf_8_char)
|
||||
endif()
|
171
sources_non_forked/editorconfig-vim/tests/core/ecvbslib.vbs
Normal file
171
sources_non_forked/editorconfig-vim/tests/core/ecvbslib.vbs
Normal file
@ -0,0 +1,171 @@
|
||||
' ecvbslib.vbs: VBScript routines for use in
|
||||
' editorconfig-core-vimscript and editorconfig-vim.
|
||||
' Copyright (c) 2018--2019 Chris White. All rights reserved.
|
||||
' Licensed CC-BY-SA, version 3.0 or any later version, at your option.
|
||||
|
||||
' Remove CR and LF in a string
|
||||
function nocrlf(strin)
|
||||
nocrlf = Replace(Replace(strin, vbCr, ""), vbLf, "")
|
||||
end function
|
||||
|
||||
' === Base64 ================================================================
|
||||
' from https://stackoverflow.com/a/40118072/2877364 by
|
||||
' https://stackoverflow.com/users/45375/mklement0
|
||||
|
||||
' Base64-encodes the specified string.
|
||||
' Parameter fAsUtf16LE determines how the input text is encoded at the
|
||||
' byte level before Base64 encoding is applied.
|
||||
' * Pass False to use UTF-8 encoding.
|
||||
' * Pass True to use UTF-16 LE encoding.
|
||||
Function Base64Encode(ByVal sText, ByVal fAsUtf16LE)
|
||||
|
||||
' Use an aux. XML document with a Base64-encoded element.
|
||||
' Assigning the byte stream (array) returned by StrToBytes() to .NodeTypedValue
|
||||
' automatically performs Base64-encoding, whose result can then be accessed
|
||||
' as the element's text.
|
||||
With CreateObject("Msxml2.DOMDocument").CreateElement("aux")
|
||||
.DataType = "bin.base64"
|
||||
if fAsUtf16LE then
|
||||
.NodeTypedValue = StrToBytes(sText, "utf-16le", 2)
|
||||
else
|
||||
.NodeTypedValue = StrToBytes(sText, "utf-8", 3)
|
||||
end if
|
||||
Base64Encode = nocrlf(.Text) ' No line breaks; MSXML adds them.
|
||||
End With
|
||||
|
||||
End Function
|
||||
|
||||
' Decodes the specified Base64-encoded string.
|
||||
' If the decoded string's original encoding was:
|
||||
' * UTF-8, pass False for fIsUtf16LE.
|
||||
' * UTF-16 LE, pass True for fIsUtf16LE.
|
||||
Function Base64Decode(ByVal sBase64EncodedText, ByVal fIsUtf16LE)
|
||||
|
||||
Dim sTextEncoding
|
||||
if fIsUtf16LE Then sTextEncoding = "utf-16le" Else sTextEncoding = "utf-8"
|
||||
|
||||
' Use an aux. XML document with a Base64-encoded element.
|
||||
' Assigning the encoded text to .Text makes the decoded byte array
|
||||
' available via .nodeTypedValue, which we can pass to BytesToStr()
|
||||
With CreateObject("Msxml2.DOMDocument").CreateElement("aux")
|
||||
.DataType = "bin.base64"
|
||||
.Text = sBase64EncodedText
|
||||
Base64Decode = BytesToStr(.NodeTypedValue, sTextEncoding)
|
||||
End With
|
||||
|
||||
End Function
|
||||
|
||||
' Returns a binary representation (byte array) of the specified string in
|
||||
' the specified text encoding, such as "utf-8" or "utf-16le".
|
||||
' Pass the number of bytes that the encoding's BOM uses as iBomByteCount;
|
||||
' pass 0 to include the BOM in the output.
|
||||
function StrToBytes(ByVal sText, ByVal sTextEncoding, ByVal iBomByteCount)
|
||||
|
||||
' Create a text string with the specified encoding and then
|
||||
' get its binary (byte array) representation.
|
||||
With CreateObject("ADODB.Stream")
|
||||
' Create a stream with the specified text encoding...
|
||||
.Type = 2 ' adTypeText
|
||||
.Charset = sTextEncoding
|
||||
.Open
|
||||
.WriteText sText
|
||||
' ... and convert it to a binary stream to get a byte-array
|
||||
' representation.
|
||||
.Position = 0
|
||||
.Type = 1 ' adTypeBinary
|
||||
.Position = iBomByteCount ' skip the BOM
|
||||
StrToBytes = .Read
|
||||
.Close
|
||||
End With
|
||||
|
||||
end function
|
||||
|
||||
' Returns a string that corresponds to the specified byte array, interpreted
|
||||
' with the specified text encoding, such as "utf-8" or "utf-16le".
|
||||
function BytesToStr(ByVal byteArray, ByVal sTextEncoding)
|
||||
|
||||
If LCase(sTextEncoding) = "utf-16le" then
|
||||
' UTF-16 LE happens to be VBScript's internal encoding, so we can
|
||||
' take a shortcut and use CStr() to directly convert the byte array
|
||||
' to a string.
|
||||
BytesToStr = CStr(byteArray)
|
||||
Else ' Convert the specified text encoding to a VBScript string.
|
||||
' Create a binary stream and copy the input byte array to it.
|
||||
With CreateObject("ADODB.Stream")
|
||||
.Type = 1 ' adTypeBinary
|
||||
.Open
|
||||
.Write byteArray
|
||||
' Now change the type to text, set the encoding, and output the
|
||||
' result as text.
|
||||
.Position = 0
|
||||
.Type = 2 ' adTypeText
|
||||
.CharSet = sTextEncoding
|
||||
BytesToStr = .ReadText
|
||||
.Close
|
||||
End With
|
||||
End If
|
||||
|
||||
end function
|
||||
|
||||
' === Runner ================================================================
|
||||
|
||||
' Run a command, copy its stdout/stderr to ours, and return its exit
|
||||
' status.
|
||||
' Modified from https://stackoverflow.com/a/32493083/2877364 by
|
||||
' https://stackoverflow.com/users/3191599/nate-barbettini .
|
||||
' See also https://www.vbsedit.com/html/4c5b06ac-dc45-4ec2-aca1-f168bab75483.asp
|
||||
function RunCommandAndEcho(strCommand)
|
||||
Const WshRunning = 0
|
||||
Const WshFinished = 1
|
||||
Const WshFailed = 2
|
||||
|
||||
Set WshShell = CreateObject("WScript.Shell")
|
||||
'WScript.Echo "Running >>" & strCommand & "<<..."
|
||||
Set WshShellExec = WshShell.Exec(strCommand)
|
||||
|
||||
Do While WshShellExec.Status = WshRunning
|
||||
'WScript.Echo "Waiting..."
|
||||
WScript.Sleep 100
|
||||
Loop
|
||||
|
||||
if not WshShellExec.StdOut.AtEndOfStream then
|
||||
WScript.StdOut.Write(WshShellExec.StdOut.ReadAll())
|
||||
end if
|
||||
|
||||
if not WshShellExec.StdErr.AtEndOfStream then
|
||||
WScript.StdErr.Write(WshShellExec.StdErr.ReadAll())
|
||||
end if
|
||||
|
||||
RunCommandAndEcho = WshShellExec.ExitCode
|
||||
end function
|
||||
|
||||
' === Argument processing ===================================================
|
||||
|
||||
function MakeY64Args(args)
|
||||
|
||||
dim b64args(100) ' 100 = arbitrary max
|
||||
|
||||
' Make Y64-flavored base64 versions of each arg so we don't have to
|
||||
' worry about quoting issues while executing PowerShell.
|
||||
|
||||
idx=0
|
||||
For Each arg In args
|
||||
b64args(idx) = Base64Encode(nocrlf(arg), False)
|
||||
' Y64 flavor of Base64
|
||||
b64args(idx) = replace( _
|
||||
replace( _
|
||||
replace(b64args(idx), "+", "."), _
|
||||
"/", "_" ), _
|
||||
"=", "-")
|
||||
'Wscript.Echo cstr(idx) & ": >" & arg & "< = >" & b64args(idx) & "<"
|
||||
'Wscript.Echo b64args(idx)
|
||||
idx = idx+1
|
||||
Next
|
||||
|
||||
MakeY64Args = b64args
|
||||
end function
|
||||
|
||||
Function QuoteForShell(strIn)
|
||||
QuoteForShell = """" & _
|
||||
replace(strIn, """", """""") & """"
|
||||
End Function
|
140
sources_non_forked/editorconfig-vim/tests/core/ecvimlib.ps1
Normal file
140
sources_non_forked/editorconfig-vim/tests/core/ecvimlib.ps1
Normal file
@ -0,0 +1,140 @@
|
||||
# ecvimlib.ps1: Editorconfig Vimscript core CLI, PowerShell version,
|
||||
# library routines.
|
||||
# Copyright (c) 2018--2019 Chris White. All rights reserved.
|
||||
# Licensed CC-BY-SA, version 3.0 or any later version, at your option.
|
||||
#
|
||||
# N.B.: debug output uses Warning only because those are displayed by default.
|
||||
|
||||
#Requires -Version 3
|
||||
|
||||
# Get the directory of this script. From
|
||||
# https://stackoverflow.com/a/5466355/2877364 by
|
||||
# https://stackoverflow.com/users/23283/jaredpar
|
||||
|
||||
$global:DIR = $PSScriptRoot
|
||||
|
||||
### Set up debugging output ============================================
|
||||
|
||||
$global:debug=$env:EDITORCONFIG_DEBUG # Debug filename
|
||||
|
||||
if($global:debug -and ($global:debug -notmatch '^/')) {
|
||||
# Relative to this script unless it starts with a slash. This is because
|
||||
# cwd is usually not $DIR when testing.
|
||||
$global:debug="${DIR}/${global:debug}"
|
||||
}
|
||||
|
||||
### Process args =======================================================
|
||||
|
||||
function de64_args($argv) {
|
||||
$argv | % {
|
||||
$b64 = $_ -replace '-','=' -replace '_','/' -replace '\.','+'
|
||||
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($b64))
|
||||
}
|
||||
}
|
||||
|
||||
### Helpers ============================================================
|
||||
|
||||
# Append a string to $debug in UTF-8 rather than the default UTF-16
|
||||
filter global:D($file = $debug) {
|
||||
if($debug) {
|
||||
echo $_ | Out-File -FilePath $file -Encoding utf8 -Append
|
||||
}
|
||||
}
|
||||
|
||||
# Escape a string for Vim
|
||||
function global:vesc($str) {
|
||||
return "'" + ($str -replace "'","''") + "'"
|
||||
}
|
||||
|
||||
# Escape a string for a command-line argument.
|
||||
# See https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.processstartinfo.arguments?view=netframework-4.7.2
|
||||
function global:argesc($arg) {
|
||||
return '"' + ($arg -replace '"','"""') + '"'
|
||||
}
|
||||
|
||||
### Find the Vim EXE ===================================================
|
||||
|
||||
function global:Find-Vim
|
||||
{
|
||||
if($env:VIM_EXE) {
|
||||
if($debug) { echo "Using env Vim $($env:VIM_EXE)" | D }
|
||||
return $env:VIM_EXE
|
||||
}
|
||||
|
||||
$vims = @(get-childitem 'c:\program files*\vim\**\vim.exe' | `
|
||||
sort LastWriteTime -Descending) # @() => always array
|
||||
|
||||
# write-host ($vims | format-table | out-string) # DEBUG
|
||||
# write-host ($vims | get-member | out-string)
|
||||
if($vims.count -gt 0) {
|
||||
if($debug) { echo "Using found Vim $($vims[0].FullName)" | D }
|
||||
return $vims[0].FullName
|
||||
}
|
||||
|
||||
throw "Could not find vim.exe. Please set VIM_EXE to the path to your Vim."
|
||||
} #Find-Vim
|
||||
|
||||
### Runner =============================================================
|
||||
|
||||
# Run a process with the given arguments.
|
||||
function global:run_process
|
||||
{
|
||||
param(
|
||||
[Parameter(Mandatory=$true, Position=0)][string]$run,
|
||||
[string]$extrapath,
|
||||
[string]$stdout, # Redirect stdout to this file
|
||||
[string]$stderr, # Redirect stderr to this file
|
||||
[string[]]$argv # Arguments to $run
|
||||
)
|
||||
$si = new-object Diagnostics.ProcessStartInfo
|
||||
if($extrapath) {
|
||||
$si.EnvironmentVariables['path']+=";${extrapath}"
|
||||
}
|
||||
$si.FileName=$run
|
||||
|
||||
# Stringify the arguments (blech)
|
||||
$argstr = $argv | % { (argesc $_) + ' ' }
|
||||
$si.Arguments = $argstr;
|
||||
|
||||
if($debug) { echo "Running process $run with arguments >>$argstr<<" | D }
|
||||
|
||||
$si.UseShellExecute=$false
|
||||
# DEBUG $si.RedirectStandardInput=$true
|
||||
if($stdout) {
|
||||
if($debug) { echo "Saving stdout to ${stdout}" | D }
|
||||
$si.RedirectStandardOutput=$true;
|
||||
}
|
||||
if($stderr) {
|
||||
if($debug) { echo "Saving stderr to ${stderr}" | D }
|
||||
$si.RedirectStandardError=$true;
|
||||
}
|
||||
|
||||
$p = [Diagnostics.Process]::Start($si)
|
||||
# DEBUG $p.StandardInput.Close() # < /dev/null
|
||||
|
||||
$p.WaitForExit()
|
||||
$retval = $p.ExitCode
|
||||
|
||||
if($stdout) {
|
||||
echo "Standard output:" | D $stdout
|
||||
$p.StandardOutput.ReadToEnd() | `
|
||||
Out-File -FilePath $stdout -Encoding utf8 -Append
|
||||
}
|
||||
|
||||
if($stderr) {
|
||||
echo "Standard error:" | D $stderr
|
||||
$p.StandardError.ReadToEnd() | `
|
||||
Out-File -FilePath $stderr -Encoding utf8 -Append
|
||||
}
|
||||
|
||||
$p.Close()
|
||||
|
||||
return $retval
|
||||
}
|
||||
|
||||
if($debug) {
|
||||
echo "======================================================" | D
|
||||
Get-Date -format F | D
|
||||
}
|
||||
|
||||
$global:VIM = Find-Vim
|
219
sources_non_forked/editorconfig-vim/tests/core/editorconfig
Normal file
219
sources_non_forked/editorconfig-vim/tests/core/editorconfig
Normal file
@ -0,0 +1,219 @@
|
||||
#!/bin/bash
|
||||
# editorconfig: Editorconfig Vimscript core CLI
|
||||
# Copyright (c) 2018--2019 Chris White. All rights reserved.
|
||||
# Licensed CC-BY-SA, version 3.0 or any later version, at your option.
|
||||
|
||||
# Documentation {{{1
|
||||
helpstr=$(cat<<'EOF'
|
||||
editorconfig: command-line invoker for the Vimscript editorconfig core
|
||||
|
||||
Normal usage:
|
||||
editorconfig [-f <config-file name>] [-b <version>]
|
||||
[-x <extra information>] <filenames...>
|
||||
|
||||
The default <config-file name> is ".editorconfig".
|
||||
If -b is given, behave as <version>.
|
||||
If -x is given, the <extra information> is included in the debug-output file.
|
||||
|
||||
Other options:
|
||||
editorconfig -h, --help Show this help
|
||||
editorconfig -v, --version Show version information
|
||||
|
||||
Environment variables:
|
||||
VIM_EXE File/path of vim (default "vim")
|
||||
EDITORCONFIG_DEBUG File/path to which to append debug output
|
||||
|
||||
EOF
|
||||
)
|
||||
|
||||
# }}}1
|
||||
|
||||
# Get the directory of this script into $this_script_dir. {{{1
|
||||
# From https://stackoverflow.com/a/246128/2877364 by
|
||||
# https://stackoverflow.com/users/407731 et al.
|
||||
|
||||
this_script_dir=
|
||||
function get_dir()
|
||||
{
|
||||
local script_source_path="${BASH_SOURCE[0]}"
|
||||
while [ -h "$script_source_path" ]; do
|
||||
# resolve $script_source_path until the file is no longer a symlink
|
||||
this_script_dir="$( cd -P "$( dirname "$script_source_path" )" >/dev/null && pwd )"
|
||||
script_source_path="$(readlink "$script_source_path")"
|
||||
[[ $script_source_path != /* ]] && script_source_path="$this_script_dir/$script_source_path"
|
||||
# if $script_source_path was a relative symlink, we need to resolve
|
||||
# it relative to the path where the symlink file was located
|
||||
done
|
||||
this_script_dir="$( cd -P "$( dirname "$script_source_path" )" >/dev/null && pwd )"
|
||||
} #get_dir()
|
||||
|
||||
get_dir
|
||||
|
||||
# }}}1
|
||||
|
||||
# Setup debug output, if $EDITORCONFIG_DEBUG is given {{{1
|
||||
debug="${EDITORCONFIG_DEBUG}" # Debug filename
|
||||
if [[ $debug && $debug != /* ]]; then # Relative to this script unless it
|
||||
debug="${this_script_dir}/${debug}" # starts with a slash. This is because
|
||||
fi # cwd is usually not $this_script_dir when testing.
|
||||
if [[ $debug ]] && ! touch "$debug"; then
|
||||
echo "Could not write file '$debug' - aborting" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
[[ $debug ]] && echo "$(date) ==================================" >> "$debug"
|
||||
|
||||
# }}}1
|
||||
|
||||
# Option processing {{{1
|
||||
|
||||
# Use a manually-specified Vim, if any
|
||||
if [[ $VIM_EXE ]]; then
|
||||
vim_pgm="$VIM_EXE"
|
||||
else
|
||||
vim_pgm="vim"
|
||||
fi
|
||||
|
||||
# Command-line options
|
||||
confname=
|
||||
ver=
|
||||
print_ver=
|
||||
extra_info=
|
||||
|
||||
while getopts 'hvf:b:-:x:' opt ; do
|
||||
case "$opt" in
|
||||
(v) print_ver=1
|
||||
;;
|
||||
|
||||
(f) confname="$OPTARG"
|
||||
;;
|
||||
|
||||
(b) ver="$OPTARG"
|
||||
;;
|
||||
|
||||
(-) case "$OPTARG" in # hacky long-option processing
|
||||
version) print_ver=1
|
||||
;;
|
||||
dummy) # A dummy option so that I can test
|
||||
# list-valued EDITORCONFIG_CMD
|
||||
;;
|
||||
help) echo "$helpstr"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
(h) echo "$helpstr"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
# A way to put the test name into the log
|
||||
(x) extra_info="$OPTARG"
|
||||
;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( $OPTIND - 1 ))
|
||||
|
||||
if [[ $print_ver ]]; then
|
||||
echo "EditorConfig VimScript Core Version 0.12.2"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if (( "$#" < 1 )); then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $1 = '-' ]]; then
|
||||
echo "Reading filenames from stdin not yet supported" 1>&2 # TODO
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# }}}1
|
||||
|
||||
# Build the Vim command line {{{1
|
||||
|
||||
fn="$(mktemp)" # Vim will write the settings into here. ~stdout.
|
||||
script_output_fn="${debug:+$(mktemp)}" # Vim's :messages. ~stderr.
|
||||
|
||||
cmd="call editorconfig_core#currbuf_cli({"
|
||||
|
||||
# Names
|
||||
cmd+="'output':'${fn//\'/\'\'}', "
|
||||
# filename to put the settings in
|
||||
[[ $debug ]] && cmd+=" 'dump':'${script_output_fn//\'/\'\'}', "
|
||||
# where to put debug info
|
||||
|
||||
# Filenames to get the settings for
|
||||
cmd+="'target':["
|
||||
for f in "$@" ; do
|
||||
cmd+="'${f//\'/\'\'}', "
|
||||
done
|
||||
cmd+="],"
|
||||
# filename to get the settings for
|
||||
|
||||
# Job
|
||||
cmd+="}, {"
|
||||
[[ $confname ]] && cmd+="'config':'${confname//\'/\'\'}', "
|
||||
# config name (e.g., .editorconfig)
|
||||
[[ $ver ]] && cmd+="'version':'${ver//\'/\'\'}', "
|
||||
# version number we should behave as
|
||||
cmd+="})"
|
||||
|
||||
vim_args=(
|
||||
-c "set runtimepath+=$this_script_dir/../.."
|
||||
-c "$cmd"
|
||||
)
|
||||
|
||||
# }}}1
|
||||
|
||||
# Run the editorconfig core through Vim {{{1
|
||||
# Thanks for options to
|
||||
# http://vim.wikia.com/wiki/Vim_as_a_system_interpreter_for_vimscript .
|
||||
# Add -V1 to the below for debugging output.
|
||||
# Do not output anything to stdout or stderr,
|
||||
# since it messes up ctest's interpretation
|
||||
# of the results.
|
||||
|
||||
"$vim_pgm" -nNes -i NONE -u NONE -U NONE \
|
||||
"${vim_args[@]}" \
|
||||
</dev/null &>> "${debug:-/dev/null}"
|
||||
vimstatus="$?"
|
||||
if [[ $vimstatus -eq 0 ]]; then
|
||||
cat "$fn"
|
||||
fi
|
||||
|
||||
# }}}1
|
||||
|
||||
# Produce debug output {{{1
|
||||
# Debug output cannot be included on stdout or stderr, because
|
||||
# ctest's regex check looks both of those places. Therefore, dump to a
|
||||
# separate debugging file.
|
||||
if [[ $debug ]]
|
||||
then
|
||||
[[ $extra_info ]] && echo "--- $extra_info ---" >> "$debug"
|
||||
echo "Vim in $vim_pgm" >> "$debug"
|
||||
echo "Current directory: $(pwd)" >> "$debug"
|
||||
echo "Script directory: $this_script_dir" >> "$debug"
|
||||
echo Vim args: "${vim_args[@]}" >> "$debug"
|
||||
#od -c <<<"${vim_args[@]}" >> "$debug"
|
||||
echo "Vim returned $vimstatus" >> "$debug"
|
||||
echo "Vim messages were: " >> "$debug"
|
||||
cat "$script_output_fn" >> "$debug"
|
||||
echo "Output was:" >> "$debug"
|
||||
od -c "$fn" >> "$debug"
|
||||
|
||||
rm -f "$script_output_fn"
|
||||
fi
|
||||
|
||||
# }}}1
|
||||
|
||||
# Cleanup {{{1
|
||||
|
||||
rm -f "$fn"
|
||||
|
||||
# }}}1
|
||||
|
||||
exit "$vimstatus" # forward the Vim exit status to the caller
|
||||
# vi: set ft=sh fdm=marker:
|
@ -0,0 +1,11 @@
|
||||
@echo off
|
||||
:: editorconfig.bat: First-level invoker for editorconfig-core-vimscript
|
||||
:: and editorconfig-vim.
|
||||
:: Just passes the full command line to editorconfig1.vbs, since VBScript
|
||||
:: applies very simple quoting rules when it parses a command line.
|
||||
:: Copyright (c) 2018--2019 Chris White. All rights reserved.
|
||||
:: Licensed CC-BY-SA, version 3.0 or any later version, at your option.
|
||||
set here=%~dp0
|
||||
|
||||
cscript //Nologo "%here%editorconfig1.vbs" %*
|
||||
:: %* has the whole command line
|
@ -0,0 +1,39 @@
|
||||
' editorconfig1.vbs: run by editorconfig.bat
|
||||
' runs editorconfig2.ps1
|
||||
' Part of editorconfig-core-vimscript and editorconfig-vim.
|
||||
'
|
||||
' Copyright (c) 2018--2019 Chris White. All rights reserved.
|
||||
' Licensed CC-BY-SA, version 3.0 or any later version, at your option.
|
||||
'
|
||||
' Modified from
|
||||
' https://stackoverflow.com/a/2470557/2877364 by
|
||||
' https://stackoverflow.com/users/2441/aphoria
|
||||
|
||||
' Thanks to https://www.geekshangout.com/vbs-script-to-get-the-location-of-the-current-script/
|
||||
currentScriptPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
|
||||
|
||||
' Load our common library. Thanks to https://stackoverflow.com/a/316169/2877364
|
||||
With CreateObject("Scripting.FileSystemObject")
|
||||
executeGlobal .openTextFile(currentScriptPath & "ecvbslib.vbs").readAll()
|
||||
End With
|
||||
|
||||
' === MAIN ==================================================================
|
||||
|
||||
' Encode all the arguments as modified base64 so there will be no quoting
|
||||
' issues when we invoke powershell.
|
||||
b64args = MakeY64Args(Wscript.Arguments)
|
||||
|
||||
' Quote script name just in case
|
||||
ps1name = QuoteForShell(currentScriptPath & "editorconfig2.ps1")
|
||||
'Wscript.Echo "Script is in " & ps1name
|
||||
|
||||
if True then
|
||||
retval = RunCommandAndEcho( "powershell.exe" & _
|
||||
" -executionpolicy bypass -file " & ps1name & " " & join(b64args) _
|
||||
)
|
||||
' add -noexit to leave window open so you can see error messages
|
||||
|
||||
WScript.Quit retval
|
||||
end if
|
||||
|
||||
' vi: set ts=4 sts=4 sw=4 et ai:
|
218
sources_non_forked/editorconfig-vim/tests/core/editorconfig2.ps1
Normal file
218
sources_non_forked/editorconfig-vim/tests/core/editorconfig2.ps1
Normal file
@ -0,0 +1,218 @@
|
||||
# editorconfig2.ps1: Editorconfig Vimscript core CLI, PowerShell version
|
||||
# Copyright (c) 2018--2019 Chris White. All rights reserved.
|
||||
# Licensed CC-BY-SA, version 3.0 or any later version, at your option.
|
||||
# Thanks to https://cecs.wright.edu/~pmateti/Courses/233/Labs/Scripting/bashVsPowerShellTable.html
|
||||
# by Gallagher and Mateti.
|
||||
|
||||
#Requires -Version 3
|
||||
|
||||
. "$PSScriptRoot\ecvimlib.ps1"
|
||||
|
||||
# Argument parsing =================================================== {{{1
|
||||
|
||||
$argv = @(de64_args($args))
|
||||
|
||||
# Defaults
|
||||
$report_version = $false
|
||||
$set_version = ''
|
||||
$config_name = '.editorconfig'
|
||||
$extra_info = ''
|
||||
$files=@()
|
||||
|
||||
# Hand-parse - pretend we're sort of like getopt.
|
||||
$idx = 0
|
||||
while($idx -lt $argv.count) {
|
||||
$a = $argv[$idx]
|
||||
|
||||
switch -CaseSensitive -Regex ($a) {
|
||||
'^(-v|--version)$' { $report_version = $true }
|
||||
|
||||
'^--dummy$' {
|
||||
# A dummy option so that I can test list-valued EDITORCONFIG_CMD
|
||||
}
|
||||
|
||||
'^-f$' {
|
||||
if($idx -eq ($argv.count-1)) {
|
||||
throw '-f <filename>: no filename provided'
|
||||
} else {
|
||||
++$idx
|
||||
$config_name = $argv[$idx]
|
||||
}
|
||||
} #-f
|
||||
|
||||
'^-b$' {
|
||||
if($idx -eq ($argv.count-1)) {
|
||||
throw '-b <version>: no version provided'
|
||||
} else {
|
||||
++$idx
|
||||
$set_version = $argv[$idx]
|
||||
}
|
||||
} #-b
|
||||
|
||||
'^-x$' {
|
||||
if($idx -eq ($argv.count-1)) {
|
||||
throw '-x <extra info>: no info provided'
|
||||
} else {
|
||||
++$idx
|
||||
$extra_info = $argv[$idx]
|
||||
}
|
||||
} #-x
|
||||
|
||||
'^--$' { # End of options, so capture the rest as filenames
|
||||
++$idx;
|
||||
while($idx -lt $argv.count) {
|
||||
$files += $argv[$idx]
|
||||
}
|
||||
}
|
||||
|
||||
default { $files += $a }
|
||||
}
|
||||
|
||||
++$idx
|
||||
} # end foreach argument
|
||||
|
||||
# }}}1
|
||||
# Argument processing ================================================ {{{1
|
||||
|
||||
if($debug) {
|
||||
if($extra_info -ne '') {
|
||||
echo "--- $extra_info --- " | D
|
||||
}
|
||||
|
||||
echo "Running in $DIR" | D
|
||||
echo "Vim executable: $VIM" | D
|
||||
echo "report version? $report_version" | D
|
||||
echo "set version to: $set_version" | D
|
||||
echo "config filename: $config_name" | D
|
||||
echo "Filenames: $files" | D
|
||||
echo "Args: $args" | D
|
||||
echo "Decoded args: $argv" | D
|
||||
}
|
||||
|
||||
if($report_version) {
|
||||
echo "EditorConfig VimScript Core Version 0.12.2"
|
||||
exit
|
||||
}
|
||||
|
||||
if($files.count -lt 1) {
|
||||
exit
|
||||
}
|
||||
|
||||
if($files[0] -eq '-') {
|
||||
echo "Reading filenames from stdin not yet supported" # TODO
|
||||
exit 1
|
||||
}
|
||||
|
||||
$fn=[System.IO.Path]::GetTempFileName();
|
||||
# Vim will write the settings into here. Sort of like stdout.
|
||||
$script_output_fn = ''
|
||||
if($debug) {
|
||||
$script_output_fn = [System.IO.Path]::GetTempFileName()
|
||||
}
|
||||
|
||||
# Permit throwing in setup commands
|
||||
$cmd = ''
|
||||
if($env:EDITORCONFIG_EXTRA) {
|
||||
$cmd += $env:EDITORCONFIG_EXTRA + ' | '
|
||||
}
|
||||
|
||||
# }}}1
|
||||
# Build Vim command line ============================================= {{{1
|
||||
$cmd += 'call editorconfig_core#currbuf_cli({'
|
||||
|
||||
# Names
|
||||
$cmd += "'output':" + (vesc($fn)) + ", "
|
||||
# filename to put the settings in
|
||||
if($debug) {
|
||||
$cmd += " 'dump':" + (vesc($script_output_fn)) + ", "
|
||||
# where to put debug info
|
||||
}
|
||||
|
||||
# Filenames to get the settings for
|
||||
$cmd += "'target':["
|
||||
ForEach ($item in $files) {
|
||||
$cmd += (vesc($item)) + ", "
|
||||
}
|
||||
$cmd += "],"
|
||||
|
||||
# Job
|
||||
$cmd += "}, {"
|
||||
if($config_name) { $cmd += "'config':" + (vesc($config_name)) + ", " }
|
||||
# config name (e.g., .editorconfig)
|
||||
if($set_version) { $cmd += "'version':" + (vesc($set_version)) + ", " }
|
||||
# version number we should behave as
|
||||
$cmd += "})"
|
||||
|
||||
#$cmd =':q!' # DEBUG
|
||||
if($debug) { echo "Using Vim command ${cmd}" | D }
|
||||
$vim_args = @(
|
||||
'-c', "set runtimepath+=${DIR}\..\..",
|
||||
'-c', $cmd,
|
||||
'-c', 'quit!' # TODO write a wrapper that will cquit on exception
|
||||
)
|
||||
|
||||
# Run editorconfig. Thanks for options to
|
||||
# http://vim.wikia.com/wiki/Vim_as_a_system_interpreter_for_vimscript .
|
||||
# Add -V1 to the below for debugging output.
|
||||
# Do not output anything to stdout or stderr,
|
||||
# since it messes up ctest's interpretation
|
||||
# of the results.
|
||||
|
||||
$basic_args = '-nNes','-i','NONE','-u','NONE','-U','NONE' #, '-V1'
|
||||
|
||||
# }}}1
|
||||
# Run Vim ============================================================ {{{1
|
||||
|
||||
if($debug) { echo "Running vim ${VIM}" | D }
|
||||
$vimstatus = run_process $VIM -stdout $debug -stderr $debug `
|
||||
-argv ($basic_args+$vim_args)
|
||||
if($debug) { echo "Done running vim" | D }
|
||||
|
||||
if($vimstatus -eq 0) {
|
||||
cat $fn
|
||||
}
|
||||
|
||||
# }}}1
|
||||
# Produce debug output =============================================== {{{1
|
||||
|
||||
# Debug output cannot be included on stdout or stderr, because
|
||||
# ctest's regex check looks both of those places. Therefore, dump to a
|
||||
# separate debugging file.
|
||||
|
||||
if($debug) {
|
||||
echo "Current directory:" | D
|
||||
(get-item -path '.').FullName | D
|
||||
echo "Script directory: $DIR" | D
|
||||
### echo Vim args: "${vim_args[@]}" >> "$debug"
|
||||
### #od -c <<<"${vim_args[@]}" >> "$debug"
|
||||
echo "Vim returned $vimstatus" | D
|
||||
echo "Vim messages were: " | D
|
||||
cat $script_output_fn | D
|
||||
echo "Output was:" | D
|
||||
|
||||
# Modified from https://www.itprotoday.com/powershell/get-hex-dumps-files-powershell
|
||||
Get-Content $script_output_fn -Encoding Byte -ReadCount 16 | `
|
||||
ForEach-Object {
|
||||
$output = ""
|
||||
$chars = ''
|
||||
foreach ( $byte in $_ ) {
|
||||
$output += "{0:X2} " -f $byte
|
||||
if( ($byte -ge 32) -and ($byte -le 127) ) {
|
||||
$chars += [char]$byte
|
||||
} else {
|
||||
$chars += '.'
|
||||
}
|
||||
}
|
||||
$output + ' ' + $chars
|
||||
} | D
|
||||
|
||||
del -Force $script_output_fn
|
||||
} #endif $debug
|
||||
|
||||
# }}}1
|
||||
|
||||
del -Force $fn
|
||||
|
||||
exit $vimstatus
|
||||
|
||||
# vi: set fdm=marker:
|
12
sources_non_forked/editorconfig-vim/tests/fetch-vim.bat
Normal file
12
sources_non_forked/editorconfig-vim/tests/fetch-vim.bat
Normal file
@ -0,0 +1,12 @@
|
||||
:: fetch-vim.bat: Fetch vim if necessary
|
||||
:: For use in the editorconfig-vim Appveyor build
|
||||
:: Copyright (c) 2018--2019 Chris White. All rights reserved.
|
||||
:: Licensed Apache 2.0, or any later version, at your option.
|
||||
|
||||
:: If it's already been loaded from the cache, we're done
|
||||
if exist C:\vim\vim\vim80\vim.exe exit
|
||||
|
||||
:: Otherwise, download and unzip it.
|
||||
appveyor DownloadFile https://github.com/cxw42/editorconfig-core-vimscript/releases/download/v0.1.0/vim.7z
|
||||
|
||||
7z x vim.7z -oC:\vim
|
41
sources_non_forked/editorconfig-vim/tests/fetch-vim.sh
Normal file
41
sources_non_forked/editorconfig-vim/tests/fetch-vim.sh
Normal file
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
# fetch-vim.bat: Fetch vim if necessary
|
||||
# For use in the editorconfig-vim Appveyor build
|
||||
# Copyright (c) 2018--2019 Chris White. All rights reserved.
|
||||
# Licensed Apache 2.0, or any later version, at your option.
|
||||
|
||||
# Debugging
|
||||
set -x
|
||||
set -o nounset
|
||||
#set -o errexit
|
||||
|
||||
# Basic system info
|
||||
uname -a
|
||||
pwd
|
||||
ls -l
|
||||
|
||||
echo "VIM_EXE: $VIM_EXE"
|
||||
set
|
||||
|
||||
# If it's already been loaded from the cache, we're done
|
||||
if [[ -x "$VIM_EXE" ]]; then
|
||||
echo Vim found in cache at "$VIM_EXE"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Otherwise, clone and build it
|
||||
WHITHER="$APPVEYOR_BUILD_FOLDER/vim"
|
||||
|
||||
git clone https://github.com/vim/vim-appimage.git
|
||||
cd vim-appimage
|
||||
git submodule update --init --recursive
|
||||
|
||||
cd vim/src
|
||||
./configure --with-features=huge --prefix="$WHITHER" --enable-fail-if-missing
|
||||
make -j2 # Free tier provides two cores
|
||||
make install
|
||||
./vim --version
|
||||
cd $APPVEYOR_BUILD_FOLDER
|
||||
find . -type f -name vim -exec ls -l {} +
|
||||
|
||||
echo Done fetching and installing vim
|
2
sources_non_forked/editorconfig-vim/tests/plugin/.gitignore
vendored
Normal file
2
sources_non_forked/editorconfig-vim/tests/plugin/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Where bundler installs local Gemfile dependencies
|
||||
/vendor/
|
5
sources_non_forked/editorconfig-vim/tests/plugin/Gemfile
Normal file
5
sources_non_forked/editorconfig-vim/tests/plugin/Gemfile
Normal file
@ -0,0 +1,5 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rake', '~> 12.3.3'
|
||||
gem 'rspec', '~> 3.4.0'
|
||||
gem 'vimrunner', '~> 0.3.1'
|
@ -0,0 +1,27 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
diff-lcs (1.2.5)
|
||||
rake (12.3.3)
|
||||
rspec (3.4.0)
|
||||
rspec-core (~> 3.4.0)
|
||||
rspec-expectations (~> 3.4.0)
|
||||
rspec-mocks (~> 3.4.0)
|
||||
rspec-core (3.4.1)
|
||||
rspec-support (~> 3.4.0)
|
||||
rspec-expectations (3.4.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.4.0)
|
||||
rspec-mocks (3.4.0)
|
||||
diff-lcs (>= 1.2.0, < 2.0)
|
||||
rspec-support (~> 3.4.0)
|
||||
rspec-support (3.4.1)
|
||||
vimrunner (0.3.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
rake (~> 12.3.3)
|
||||
rspec (~> 3.4.0)
|
||||
vimrunner (~> 0.3.1)
|
@ -0,0 +1,8 @@
|
||||
#
|
||||
# run `rake` to run tests
|
||||
|
||||
require 'rspec/core/rake_task'
|
||||
|
||||
RSpec::Core::RakeTask.new(:spec)
|
||||
|
||||
task :default => :spec
|
@ -0,0 +1,4 @@
|
||||
[*.rb]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
@ -0,0 +1,161 @@
|
||||
require 'vimrunner'
|
||||
|
||||
def create_vim(*initial_commands)
|
||||
vim = Vimrunner.start
|
||||
initial_commands.each do |cmd|
|
||||
vim.command cmd
|
||||
end
|
||||
vim.add_plugin(File.expand_path('../../../..', __FILE__), 'plugin/editorconfig.vim')
|
||||
return vim
|
||||
end
|
||||
|
||||
# The base path of the testing files
|
||||
BASE_PATH = File.expand_path('../plugin_tests/test_files/', __FILE__)
|
||||
|
||||
# file_name is the file name that should be open by Vim
|
||||
# expected_values is a Hash that contains all the Vim options we need to test
|
||||
def test_editorconfig(vim, file_name, expected_values)
|
||||
vim.edit(File.join(BASE_PATH, file_name))
|
||||
|
||||
expected_values.each do |key, val|
|
||||
expect(vim.echo("&l:#{key}")).to eq(val)
|
||||
end
|
||||
|
||||
vim.command 'bd!'
|
||||
end
|
||||
|
||||
def test_instance(vim)
|
||||
describe 'plugin/editorconfig.vim' do
|
||||
after(:all) do
|
||||
vim.kill
|
||||
end
|
||||
|
||||
describe '#all' do
|
||||
it '3_space.py' do
|
||||
test_editorconfig vim, '3_space.txt',
|
||||
expandtab: '1',
|
||||
shiftwidth: '3',
|
||||
tabstop: '3'
|
||||
end
|
||||
end
|
||||
|
||||
it '4_space.py' do
|
||||
test_editorconfig vim, '4_space.py',
|
||||
expandtab: '1',
|
||||
shiftwidth: '4',
|
||||
tabstop: '8'
|
||||
end
|
||||
|
||||
it 'space.txt' do
|
||||
test_editorconfig vim, 'space.txt',
|
||||
expandtab: '1',
|
||||
shiftwidth: vim.echo('&l:tabstop')
|
||||
end
|
||||
|
||||
it 'tab.txt' do
|
||||
test_editorconfig vim, 'tab.txt',
|
||||
expandtab: '0'
|
||||
end
|
||||
|
||||
it '4_tab.txt' do
|
||||
test_editorconfig vim, '4_tab.txt',
|
||||
expandtab: '0',
|
||||
shiftwidth: '4',
|
||||
tabstop: '4'
|
||||
end
|
||||
|
||||
it '4_tab_width_of_8' do
|
||||
test_editorconfig vim, '4_tab_width_of_8.txt',
|
||||
expandtab: '0',
|
||||
shiftwidth: '4',
|
||||
tabstop: '8'
|
||||
end
|
||||
|
||||
it 'lf.txt' do
|
||||
test_editorconfig vim, 'lf.txt',
|
||||
fileformat: 'unix'
|
||||
end
|
||||
|
||||
it 'crlf.txt' do
|
||||
test_editorconfig vim, 'crlf.txt',
|
||||
fileformat: 'dos'
|
||||
end
|
||||
|
||||
it 'cr.txt' do
|
||||
test_editorconfig vim, 'cr.txt',
|
||||
fileformat: 'mac'
|
||||
end
|
||||
|
||||
it 'utf-8.txt' do
|
||||
test_editorconfig vim, 'utf-8.txt',
|
||||
fileencoding: 'utf-8',
|
||||
bomb: '0'
|
||||
end
|
||||
|
||||
it 'utf-8-bom.txt' do
|
||||
test_editorconfig vim, 'utf-8-bom.txt',
|
||||
fileencoding: 'utf-8',
|
||||
bomb: '1'
|
||||
end
|
||||
|
||||
it 'utf-16be.txt' do
|
||||
test_editorconfig vim, 'utf-16be.txt',
|
||||
fileencoding: 'utf-16'
|
||||
end
|
||||
|
||||
it 'utf-16le.txt' do
|
||||
test_editorconfig vim, 'utf-16le.txt',
|
||||
fileencoding: 'utf-16le'
|
||||
end
|
||||
|
||||
it 'latin1.txt' do
|
||||
test_editorconfig vim, 'latin1.txt',
|
||||
fileencoding: 'latin1'
|
||||
end
|
||||
|
||||
# insert_final_newline by PreserveNoEOL tests are omitted, since they are not supported
|
||||
if vim.echo("exists('+fixendofline')") == '1'
|
||||
it 'with_newline.txt' do
|
||||
test_editorconfig vim, 'with_newline.txt',
|
||||
fixendofline: '1'
|
||||
end
|
||||
|
||||
it 'without_newline.txt' do
|
||||
test_editorconfig vim, 'without_newline.txt',
|
||||
fixendofline: '0'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Test the vim core
|
||||
(lambda do
|
||||
puts 'Testing default'
|
||||
vim = create_vim
|
||||
test_instance vim
|
||||
end).call
|
||||
|
||||
# Test the vim core with an express setting
|
||||
(lambda do
|
||||
puts 'Testing with express vim_core mode'
|
||||
vim = create_vim("let g:EditorConfig_core_mode='vim_core'")
|
||||
test_instance vim
|
||||
end).call
|
||||
|
||||
# Test with external-core mode, but no external core defined
|
||||
(lambda do
|
||||
puts 'Testing with fallback to vim_core mode'
|
||||
vim = create_vim("let g:EditorConfig_core_mode='external_command'")
|
||||
test_instance vim
|
||||
end).call
|
||||
|
||||
# Test with an external core, if desired
|
||||
extcore = ENV['EDITORCONFIG_VIM_EXTERNAL_CORE']
|
||||
if extcore
|
||||
puts "Testing with external_command #{extcore}"
|
||||
vim = create_vim(
|
||||
"let g:EditorConfig_core_mode='external_command'",
|
||||
"let g:EditorConfig_exec_path='#{extcore}'",
|
||||
)
|
||||
test_instance vim
|
||||
end
|
45
sources_non_forked/editorconfig-vim/tests/travis-test.sh
Normal file
45
sources_non_forked/editorconfig-vim/tests/travis-test.sh
Normal file
@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# travis-test.sh: Script for running editorconfig-vim tests under Travis CI.
|
||||
# Copyright (c) 2019 Chris White. All rights reserved.
|
||||
# Licensed Apache, version 2.0 or any later version, at your option.
|
||||
|
||||
# Error exit; debug output
|
||||
set -vxEeuo pipefail
|
||||
|
||||
# Permit `travis-test.sh plugin` if TEST_WHICH is unset
|
||||
if [[ ( ! "${TEST_WHICH:-}" ) && "${1:-}" ]]; then
|
||||
export TEST_WHICH="$1"
|
||||
fi
|
||||
|
||||
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
|
Reference in New Issue
Block a user