diff options
Diffstat (limited to 'runtime/pack/dist/opt/editorconfig/tests')
17 files changed, 1216 insertions, 0 deletions
diff --git a/runtime/pack/dist/opt/editorconfig/tests/core/CMakeLists.txt b/runtime/pack/dist/opt/editorconfig/tests/core/CMakeLists.txt new file mode 100644 index 0000000000..2c124403b8 --- /dev/null +++ b/runtime/pack/dist/opt/editorconfig/tests/core/CMakeLists.txt @@ -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) diff --git a/runtime/pack/dist/opt/editorconfig/tests/core/CTestCustom.cmake b/runtime/pack/dist/opt/editorconfig/tests/core/CTestCustom.cmake new file mode 100644 index 0000000000..fbea6f97ea --- /dev/null +++ b/runtime/pack/dist/opt/editorconfig/tests/core/CTestCustom.cmake @@ -0,0 +1,41 @@ +# 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() + +# Skip min_supported_value_length on Windows since that test seems to +# cause Appveyor to hang. +if(WIN32) + message(WARNING "Skipping min_supported_value_length test on this platform") + set(CTEST_CUSTOM_TESTS_IGNORE ${CTEST_CUSTOM_TESTS_IGNORE} min_supported_value_length) +endif() diff --git a/runtime/pack/dist/opt/editorconfig/tests/core/ecvbslib.vbs b/runtime/pack/dist/opt/editorconfig/tests/core/ecvbslib.vbs new file mode 100755 index 0000000000..a1e05d241d --- /dev/null +++ b/runtime/pack/dist/opt/editorconfig/tests/core/ecvbslib.vbs @@ -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
diff --git a/runtime/pack/dist/opt/editorconfig/tests/core/ecvimlib.ps1 b/runtime/pack/dist/opt/editorconfig/tests/core/ecvimlib.ps1 new file mode 100755 index 0000000000..45387d5aa0 --- /dev/null +++ b/runtime/pack/dist/opt/editorconfig/tests/core/ecvimlib.ps1 @@ -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
diff --git a/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig b/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig new file mode 100755 index 0000000000..bdb5971d65 --- /dev/null +++ b/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig @@ -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: diff --git a/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig.bat b/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig.bat new file mode 100755 index 0000000000..77b544700e --- /dev/null +++ b/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig.bat @@ -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
diff --git a/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig1.vbs b/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig1.vbs new file mode 100755 index 0000000000..488411fcf8 --- /dev/null +++ b/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig1.vbs @@ -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:
diff --git a/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig2.ps1 b/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig2.ps1 new file mode 100755 index 0000000000..0bc3602a19 --- /dev/null +++ b/runtime/pack/dist/opt/editorconfig/tests/core/editorconfig2.ps1 @@ -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
|