Skip to content

Commit

Permalink
Formal changes; minor bugfix
Browse files Browse the repository at this point in the history
- Update copyright date to 2018
- Consistent formatting: no spaces inside the wrapping parans on CMake
  function calls
- Change EQUAL to STREQUAL where appropriate
  • Loading branch information
Chris White committed Nov 21, 2018
1 parent e631ba8 commit dd9e054
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 80 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011-2012 EditorConfig Team
# Copyright (c) 2011-2018 EditorConfig Team
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -30,8 +30,8 @@
project(editorconfig-core-test NONE)

# Where this file lives
set( tests_cmakelists_dir "${CMAKE_CURRENT_LIST_DIR}" )
#message( STATUS "Tests are in ${tests_cmakelists_dir}" )
set(tests_cmakelists_dir "${CMAKE_CURRENT_LIST_DIR}")
#message(STATUS "Tests are in ${tests_cmakelists_dir}")

# Only when we are using editorconfig-core-test independently should we check
# cmake version, set EDITORCONFIG_CMD as cache string, and enable_testing()
Expand Down Expand Up @@ -65,8 +65,8 @@ endfunction()
# A test that returns multiple lines of output. CAUTION: filenames used in
# these tests may not contain semicolons.
function(new_ec_test_multiline name ec_file src_file regex)
#message( STATUS "Building multiline test ${name} with tests_cmakelists_dir ${tests_cmakelists_dir}" )
#message( STATUS "List dir ${CMAKE_CURRENT_LIST_DIR}, source dir ${CMAKE_CURRENT_SOURCE_DIR}" )
#message(STATUS "Building multiline test ${name} with tests_cmakelists_dir ${tests_cmakelists_dir}")
#message(STATUS "List dir ${CMAKE_CURRENT_LIST_DIR}, source dir ${CMAKE_CURRENT_SOURCE_DIR}")
add_test(${name} "cmake"
"-D" "EDITORCONFIG_CMD=${EDITORCONFIG_CMD}"
# Since variables aren't autpmatically passed to the inner cmake
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011-2016 EditorConfig Team
Copyright (c) 2011-2018 EditorConfig Team
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
2 changes: 1 addition & 1 deletion cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011-2012 EditorConfig Team
# Copyright (c) 2011-2018 EditorConfig Team
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down
12 changes: 6 additions & 6 deletions cmake/almostcat.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@

cmake_minimum_required(VERSION 3.5)

if( "${WHICH}" EQUAL "" )
message( FATAL_ERROR "No WHICH parameter specified" )
if("${WHICH}" STREQUAL "")
message(FATAL_ERROR "No WHICH parameter specified")
return()
endif()

#message( FATAL_ERROR " Reading ${WHICH}" ) # Uncomment for debugging
file( READ "${WHICH}" contents )
#message(FATAL_ERROR " Reading ${WHICH}") # Uncomment for debugging
file(READ "${WHICH}" contents)

# message() will give us an extra \n, so trim one if we can.
string( REGEX REPLACE "(\r\n|\r|\n)$" "" lines "${lines}" )
string(REGEX REPLACE "(\r\n|\r|\n)$" "" lines "${lines}")

# Print, with a leading space as noted above.
message( " ${contents}" )
message(" ${contents}")
24 changes: 12 additions & 12 deletions cmake/ec_sort.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,35 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

cmake_minimum_required( VERSION 3.5 )
cmake_minimum_required(VERSION 3.5)

# See documentation links at https://stackoverflow.com/q/12802377/2877364
set( tests_cmake_ec_sort_dir "${CMAKE_CURRENT_LIST_DIR}" )
list( APPEND CMAKE_MODULE_PATH "${tests_cmake_ec_sort_dir}/../cmake" )
include( runandsort )
set(tests_cmake_ec_sort_dir "${CMAKE_CURRENT_LIST_DIR}")
list(APPEND CMAKE_MODULE_PATH "${tests_cmake_ec_sort_dir}/../cmake")
include(runandsort)

# Required parameters are in variables: EDITORCONFIG_CMD and ECARGS
if( "${ECARGS}" EQUAL "" )
message( FATAL_ERROR "No ECARGS parameter specified" )
if("${ECARGS}" STREQUAL "")
message(FATAL_ERROR "No ECARGS parameter specified")
return()
endif()

# Uncomment for debugging
#message( FATAL_ERROR " Running ${EDITORCONFIG_CMD} with ${ECARGS}" )
#message(FATAL_ERROR " Running ${EDITORCONFIG_CMD} with ${ECARGS}")

run_and_sort( RETVAL lines RETVAL_FAILURE did_fail
run_and_sort(RETVAL lines RETVAL_FAILURE did_fail
PGM "${EDITORCONFIG_CMD}"
ARGS ${ECARGS}
)

if( ${did_fail} )
message( FATAL_ERROR "${EDITORCONFIG_CMD} ${ECARGS} returned a nonzero exit code" )
if(${did_fail})
message(FATAL_ERROR "${EDITORCONFIG_CMD} ${ECARGS} returned a nonzero exit code")
return()
endif()

# message() will give us an extra \n, so trim one if we can.
string( REGEX REPLACE "(\r\n|\r|\n)$" "" lines "${lines}" )
string(REGEX REPLACE "(\r\n|\r|\n)$" "" lines "${lines}")

# Output **to stderr**. If we used message(STATUS...), it would print to
# stdout but also emit a leading "--".
message( "${lines}" )
message("${lines}")
74 changes: 37 additions & 37 deletions cmake/runandsort.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

cmake_minimum_required( VERSION 3.5 )
cmake_minimum_required(VERSION 3.5)

# Conventions:
# - "P_*" are parameters parsed using cmake_parse_arguments
Expand Down Expand Up @@ -61,72 +61,72 @@ cmake_minimum_required( VERSION 3.5 )
# The sorted stdout of PGM, or the FAILURE string if PGM failed.
# PGM's stderr is ignored.

function( run_and_sort )
function(run_and_sort)
# Argument parsing
set( option_keywords CAPTURE_STDERR TRIM_INITIAL_LEADING_SPACE )
set( one_value_keywords RETVAL RETVAL_FAILURE PGM )
set( multi_value_keywords ARGS )
cmake_parse_arguments( P "${option_keywords}" "${one_value_keywords}"
"${multi_value_keywords}" ${ARGN} )

#message( STATUS "Running ${P_PGM} with ${P_ARGS}" )
execute_process( COMMAND "${P_PGM}" ${P_ARGS}
set(option_keywords CAPTURE_STDERR TRIM_INITIAL_LEADING_SPACE)
set(one_value_keywords RETVAL RETVAL_FAILURE PGM)
set(multi_value_keywords ARGS)
cmake_parse_arguments(P "${option_keywords}" "${one_value_keywords}"
"${multi_value_keywords}" ${ARGN})

#message(STATUS "Running ${P_PGM} with ${P_ARGS}")
execute_process(COMMAND "${P_PGM}" ${P_ARGS}
RESULT_VARIABLE ep_retval
OUTPUT_VARIABLE ep_stdout
ERROR_VARIABLE ep_stderr
)
)

# Which one are we processing?
if( ${P_CAPTURE_STDERR} )
set( ep_out "${ep_stderr}" )
if(${P_CAPTURE_STDERR})
set(ep_out "${ep_stderr}")
else()
set( ep_out "${ep_stdout}" )
set(ep_out "${ep_stdout}")
endif()

#message( STATUS "Got stdout =${ep_stdout}=" )
#message( STATUS "Got stderr =${ep_stderr}=" )
#message(STATUS "Got stdout =${ep_stdout}=")
#message(STATUS "Got stderr =${ep_stderr}=")

# Early bail on failure
if( NOT( "${ep_retval}" EQUAL "0" ) )
set( ${P_RETVAL} "" PARENT_SCOPE )
if( "${P_RETVAL_FAILURE}" MATCHES "." ) # if we got a name
set( ${P_RETVAL_FAILURE} TRUE PARENT_SCOPE )
if(NOT("${ep_retval}" EQUAL "0"))
set(${P_RETVAL} "" PARENT_SCOPE)
if("${P_RETVAL_FAILURE}" MATCHES ".") # if we got a name
set(${P_RETVAL_FAILURE} TRUE PARENT_SCOPE)
endif()
return()
endif()

# Trim hack
if( ${P_TRIM_INITIAL_LEADING_SPACE} )
string( REGEX REPLACE "^[ ]+" "" ep_out "${ep_out}" )
if(${P_TRIM_INITIAL_LEADING_SPACE})
string(REGEX REPLACE "^[ ]+" "" ep_out "${ep_out}")
endif()

# Change all the semicolons in the output to \x01
string( ASCII 1 ONE )
string( REPLACE ";" "${ONE}" ep_out "${ep_out}" )
#message( STATUS "After escaping =${ep_out}=" )
string(ASCII 1 ONE)
string(REPLACE ";" "${ONE}" ep_out "${ep_out}")
#message(STATUS "After escaping =${ep_out}=")

# Normalize line endings, just in case
string( REGEX REPLACE "\r|\n|\r\n" "\n" ep_out "${ep_out}" )
#message( STATUS "After line-endings =${ep_out}=" )
string(REGEX REPLACE "\r|\n|\r\n" "\n" ep_out "${ep_out}")
#message(STATUS "After line-endings =${ep_out}=")

# Turn the string into a list
string( REPLACE "\n" ";" ep_out "${ep_out}" )
#message( STATUS "After listifying =${ep_out}=" )
string(REPLACE "\n" ";" ep_out "${ep_out}")
#message(STATUS "After listifying =${ep_out}=")

# Sort the list
list( SORT ep_out )
list(SORT ep_out)

# Back to individual lines
string( REPLACE ";" "\n" ep_out "${ep_out}" )
#message( STATUS "After back to lines =${ep_out}=" )
string(REPLACE ";" "\n" ep_out "${ep_out}")
#message(STATUS "After back to lines =${ep_out}=")

# And back to semicolons. Note: I am not trying to reverse line endings.
string( REPLACE "${ONE}" ";" ep_out "${ep_out}" )
#message( STATUS "After unescaping =${ep_out}=" )
string(REPLACE "${ONE}" ";" ep_out "${ep_out}")
#message(STATUS "After unescaping =${ep_out}=")

# Out to the caller
set( ${P_RETVAL} "${ep_out}" PARENT_SCOPE )
#message( STATUS "Returned =${ep_out}=" )
set(${P_RETVAL} "${ep_out}" PARENT_SCOPE)
#message(STATUS "Returned =${ep_out}=")

endfunction( run_and_sort )
endfunction(run_and_sort)

4 changes: 2 additions & 2 deletions filetree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011-2012 EditorConfig Team
# Copyright (c) 2011-2018 EditorConfig Team
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -82,7 +82,7 @@ new_ec_test(windows_separator path_separator.in windows/separator "^[ \t\n\r]*$"
new_ec_test(windows_separator2 path_separator.in windows/separator2 "^[ \t\n\r]*$")

# Globs with backslash in it but should be considered as file name on Non-Windows system
if( (NOT WIN32) AND (NOT CYGWIN) )
if((NOT WIN32) AND (NOT CYGWIN))
new_ec_test(backslash_not_on_windows path_separator.in "windows\\\\separator2" "^key4=value4[ \t\n\r]*$")
endif()

Expand Down
5 changes: 2 additions & 3 deletions glob/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011-2014 EditorConfig Team
# Copyright (c) 2011-2018 EditorConfig Team
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand All @@ -24,7 +24,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#


# Tests for *

# matches a single characters
Expand Down Expand Up @@ -177,7 +176,7 @@ new_ec_test(braces_escaped_brace3 braces.in f.txt "^closing=yes[ \t\n\r]*$")

# escaped backslash
new_ec_test(braces_escaped_backslash1 braces.in g.txt "^backslash=yes[ \t\n\r]*$")
if( (NOT WIN32) AND (NOT CYGWIN) ) # this case is impossible on Windows.
if((NOT WIN32) AND (NOT CYGWIN)) # this case is impossible on Windows.
new_ec_test(braces_escaped_backslash2 braces.in \\\\.txt "^backslash=yes[ \t\n\r]*$")
endif()
new_ec_test(braces_escaped_backslash3 braces.in i.txt "^backslash=yes[ \t\n\r]*$")
Expand Down
18 changes: 9 additions & 9 deletions meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

cmake_minimum_required( VERSION 3.5 )
cmake_minimum_required(VERSION 3.5)

set( tests_meta_cmakelists_dir "${CMAKE_CURRENT_LIST_DIR}" )
set(tests_meta_cmakelists_dir "${CMAKE_CURRENT_LIST_DIR}")

# Line separator regex, for convenience
set( L "[ \t\n\r]+" )
set(L "[ \t\n\r]+")

message( STATUS "meta: Using editorconfig ${EDITORCONFIG_CMD}" )
message(STATUS "meta: Using editorconfig ${EDITORCONFIG_CMD}")

# Test run_and_sort()
add_test( meta_runandsort cmake -P "${tests_meta_cmakelists_dir}/sample.cmake" )
set_tests_properties( meta_runandsort PROPERTIES PASS_REGULAR_EXPRESSION
"^[\n]*0${L}a;b${L}b;c${L}b;e${L}b;f${L}c;b;a${L}d${L}$" )
add_test(meta_runandsort cmake -P "${tests_meta_cmakelists_dir}/sample.cmake")
set_tests_properties(meta_runandsort PROPERTIES PASS_REGULAR_EXPRESSION
"^[\n]*0${L}a;b${L}b;c${L}b;e${L}b;f${L}c;b;a${L}d${L}$")
# Have to permit leading \n's - I don't know how to get rid of them

# Test the new multiline macro on a simple case
new_ec_test_multiline( meta_multiline meta.in meta.c
"^[\n]*answer=42${L}$" )
new_ec_test_multiline(meta_multiline meta.in meta.c
"^[\n]*answer=42${L}$")
2 changes: 1 addition & 1 deletion parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011-2013 EditorConfig Team
# Copyright (c) 2011-2018 EditorConfig Team
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down
5 changes: 2 additions & 3 deletions properties/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011-2012 EditorConfig Team
# Copyright (c) 2011-2018 EditorConfig Team
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand All @@ -24,7 +24,6 @@
# POSSIBILITY OF SUCH DAMAGE.
#


# test tab_width default
new_ec_test_multiline(tab_width_default_ML tab_width_default.in test.c
"indent_size=4[ \t]*[\n\r]+indent_style=space[ \t]*[\n\r]+tab_width=4[\t\n\r]*")
Expand Down Expand Up @@ -57,7 +56,7 @@ new_ec_test_multiline(indent_size_default_with_tab_width_ML

# test that same property values are lowercased (v0.9.0 properties)
new_ec_test_multiline(lowercase_values1_ML lowercase_values.in test1.c
"end_of_line=crlf[ \t]*[\n\r]+indent_style=space[ \t\n\r]*" )
"end_of_line=crlf[ \t]*[\n\r]+indent_style=space[ \t\n\r]*")

# test that same property values are lowercased (v0.9.0 properties)
new_ec_test_multiline(lowercase_values2_ML lowercase_values.in test2.c
Expand Down

0 comments on commit dd9e054

Please sign in to comment.