Skip to content

Commit

Permalink
Rewrote multiline tests to use new harness
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris White committed Nov 18, 2018
1 parent fc0de11 commit 6b18aa9
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 53 deletions.
13 changes: 8 additions & 5 deletions cli/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#
# Copyright (c) 2011-2012 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
Expand Down Expand Up @@ -40,10 +40,13 @@ set_tests_properties(test_short_version_switch PROPERTIES

# Test for multiple input files

# when files are specified on command line
# when files are specified on command line. The files can appear in either
# order in the output, but each file's output line must be grouped with its
# file header. Handle this by listing both possibilities manually in the regex.
add_test(multiple_files_on_command_line ${EDITORCONFIG_CMD} -f cli.in
"${CMAKE_CURRENT_SOURCE_DIR}/file1.c"
"${CMAKE_CURRENT_SOURCE_DIR}/file2.cpp")
set_tests_properties(multiple_files_on_command_line PROPERTIES
PASS_REGULAR_EXPRESSION
"^\\[${CMAKE_CURRENT_SOURCE_DIR}/file1.c\\][ \t]*[\n\r]+key1=value1[ \t]*[\n\r]+\\[${CMAKE_CURRENT_SOURCE_DIR}/file2.cpp\\][ \t]*[\n\r]+key2=value2[ \t\n\r]*$")
"^(\\[${CMAKE_CURRENT_SOURCE_DIR}/file1.c\\][ \t]*[\n\r]+key1=value1[ \t]*[\n\r]+\\[${CMAKE_CURRENT_SOURCE_DIR}/file2.cpp\\][ \t]*[\n\r]+key2=value2)|(\\[${CMAKE_CURRENT_SOURCE_DIR}/file2.cpp\\][ \t]*[\n\r]+key2=value2[ \t]*[\n\r]+\\[${CMAKE_CURRENT_SOURCE_DIR}/file1.c\\][ \t]*[\n\r]+key1=value1)[ \t\n\r]*$"
)
22 changes: 13 additions & 9 deletions filetree/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#
# Copyright (c) 2011-2012 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
Expand All @@ -29,7 +29,9 @@
new_ec_test(parent_directory parent_directory.in parent_directory/test.a "^key=value[ \t\n\r]*$")

# Test for EditorConfig file in parent directory and current directory
new_ec_test(parent_and_current_dir parent_directory.in parent_directory/test.b "^key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*$")
new_ec_test_multiline(parent_and_current_dir_ML
parent_directory.in parent_directory/test.b
"key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*")

# Test for file in parent directory and overloaded by file in current directory
new_ec_test(parent_dir_overload parent_directory.in parent_directory/test.c "^key=valueB[ \t\n\r]*$")
Expand All @@ -50,13 +52,13 @@ new_ec_test(root_file_mixed_case root_file.in root_mixed/test.a "^child=true[ \t
new_ec_test(root_pattern root_file.in root "^name=root[ \t\n\r]*$")

# Tests path separator match
new_ec_test(path_separator path_separator.in path/separator "^key=value[ \t\n\r]*$")
new_ec_test(path_separator path_separator.in path/separator "^key1=value1[ \t\n\r]*$")

# Windows style path separator in the command line should work on Windows, but
# should not work on other systems
# TODO figure out how to handle Cygwin
if(WIN32)
set(path_separator_backslash_in_cmd_line_regex "^key=value[ \t\n\r]*$")
set(path_separator_backslash_in_cmd_line_regex "^key1=value1[ \t\n\r]*$")
else(WIN32)
set(path_separator_backslash_in_cmd_line_regex "^[ \t\n\r]*$")
endif(WIN32)
Expand All @@ -68,7 +70,7 @@ new_ec_test_full_ec_file_path(path_separator_backslash_in_cmd_line
new_ec_test(nested_path_separator path_separator.in nested/path/separator "^[ \t\n\r]*$")

# Tests path separator match top of path only
new_ec_test(top_level_path_separator path_separator.in top/of/path "^key=value[ \t\n\r]*$")
new_ec_test(top_level_path_separator path_separator.in top/of/path "^key2=value2[ \t\n\r]*$")

# Tests path separator match top of path only
new_ec_test(top_level_path_separator_neg path_separator.in not/top/of/path "^[ \t\n\r]*$")
Expand All @@ -81,15 +83,17 @@ 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) )
new_ec_test(backslash_not_on_windows path_separator.in "windows\\\\separator2" "^key=value[ \t\n\r]*$")
new_ec_test(backslash_not_on_windows path_separator.in "windows\\\\separator2" "^key4=value4[ \t\n\r]*$")
endif()

new_ec_test(path_with_special_chars path_with_special_chars.in "path_with_special_[chars/test.a" "^key=value[ \t\n\r]*$")
## " <-- resync the syntax highlighter

# Test the unset value with various common properties
new_ec_test(unset_charset unset.in unset/charset.txt "^charset=unset[ \t\n\r]*$")
new_ec_test(unset_end_of_line unset.in unset/end_of_line.txt "^end_of_line=unset[ \t\n\r]*$")
new_ec_test(unset_indent_size unset.in unset/indent_size.txt "^indent_size=unset[ \t\n\r]*tab_width=unset[ \t\n\r]*$")
new_ec_test_multiline(unset_indent_size_ML unset.in unset/indent_size.txt
"indent_size=unset[ \t\n\r]*tab_width=unset[ \t\n\r]*")
new_ec_test(unset_indent_style unset.in unset/indent_style.txt "^indent_style=unset[ \t\n\r]*$")
new_ec_test(unset_insert_final_newline unset.in unset/insert_final_newline.txt "^insert_final_newline=unset[ \t\n\r]*$")
new_ec_test(unset_tab_width unset.in unset/tab_width.txt "^tab_width=unset[ \t\n\r]*$")
Expand Down
8 changes: 4 additions & 4 deletions filetree/path_separator.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
root=true

[path/separator]
key=value
key1=value1

[/top/of/path]
key=value
key2=value2

[windows\separator]
key=value
key3=value3

[windows\\separator2]
key=value
key4=value4
16 changes: 8 additions & 8 deletions glob/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#
# Copyright (c) 2011-2014 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
Expand All @@ -28,22 +28,22 @@
# Tests for *

# matches a single characters
new_ec_test(star_single star.in ace.c "^key=value[ \t\n\r]*keyc=valuec[ \t\n\r]*$")
new_ec_test_multiline(star_single_ML star.in ace.c "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*")

# matches zero characters
new_ec_test(star_zero star.in ae.c "^key=value[ \t\n\r]*keyc=valuec[ \t\n\r]*$")
new_ec_test_multiline(star_zero_ML star.in ae.c "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*")

# matches multiple characters
new_ec_test(star_multiple star.in abcde.c "^key=value[ \t\n\r]*keyc=valuec[ \t\n\r]*$")
new_ec_test_multiline(star_multiple_ML star.in abcde.c "key=value[ \t\n\r]+keyc=valuec[ \t\n\r]*")

# does not match path separator
new_ec_test(star_over_slash star.in a/e.c "^[ \t\n\r]*keyc=valuec[ \t\n\r]*$")

# star after a slash
new_ec_test(star_after_slash star.in Bar/foo.txt "^keyb=valueb[ \t\n\r]*keyc=valuec[ \t\n\r]*$")
new_ec_test_multiline(star_after_slash_ML star.in Bar/foo.txt "keyb=valueb[ \t\n\r]+keyc=valuec[ \t\n\r]*")

# star matches a dot file after slash
new_ec_test(star_matches_dot_file_after_slash star.in Bar/.editorconfig "^keyb=valueb[ \t\n\r]*keyc=valuec[ \t\n\r]*$")
new_ec_test_multiline(star_matches_dot_file_after_slash_ML star.in Bar/.editorconfig "keyb=valueb[ \t\n\r]+keyc=valuec[ \t\n\r]*")

# star matches a dot file
new_ec_test(star_matches_dot_file star.in .editorconfig "^keyc=valuec[ \t\n\r]*$")
Expand Down
25 changes: 13 additions & 12 deletions parser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#
# Copyright (c) 2011-2013 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
Expand All @@ -27,8 +27,8 @@
# Basic parser tests

# test repeat sections
new_ec_test(repeat_sections basic.in a.a "^option1=value1[ \t]*[\n\r]+option2=value2[ \t\n\r]*$")
new_ec_test(basic_cascade basic.in b.b "^option1=c[ \t]*[\n\r]+option2=b[ \t\n\r]*$")
new_ec_test_multiline(repeat_sections_ML basic.in a.a "option1=value1[ \t]*[\n\r]+option2=value2[ \t\n\r]*")
new_ec_test_multiline(basic_cascade_ML basic.in b.b "option1=c[ \t]*[\n\r]+option2=b[ \t\n\r]*")

# Tests for whitespace parsing

Expand All @@ -52,8 +52,8 @@ new_ec_test(spaces_after_property_value whitespace.in test5.c
"^key=value[ \t\n\r]*$")

# test blank lines between properties
new_ec_test(blank_lines_between_properties whitespace.in test6.c
"^key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*$")
new_ec_test_multiline(blank_lines_between_properties_ML whitespace.in test6.c
"key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*")

# test spaces in section name
new_ec_test(spaces_in_section_name whitespace.in " test 7 "
Expand All @@ -67,7 +67,8 @@ new_ec_test(spaces_before_section_name whitespace.in test8.c
new_ec_test(spaces_after_section_name whitespace.in test9.c "^key=value[ \t\n\r]*$")

# test spaces at beginning of line between properties
new_ec_test(spaces_before_middle_property whitespace.in test10.c "^key1=value1[ \t]*[\n\r]+key2=value2[ \t]*[\n\r]+key3=value3[ \t\n\r]*$")
new_ec_test_multiline(spaces_before_middle_property_ML whitespace.in test10.c
"key1=value1[ \t]*[\n\r]+key2=value2[ \t]*[\n\r]+key3=value3[ \t\n\r]*")

# test colon seperator with no whitespaces in property assignment
new_ec_test(colon_sep_no_whitespace whitespace.in test1.d "^key=value[ \t\n\r]*$")
Expand Down Expand Up @@ -104,8 +105,8 @@ new_ec_test(comment_before_props comments.in test3.c
"^key=value[ \t\n\r]*$")

# test comments ignored between properties
new_ec_test(comment_between_props comments.in test4.c
"^key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*$")
new_ec_test_multiline(comment_between_props_ML comments.in test4.c
"key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*")

# test semicolons at end of property value are included in value
new_ec_test(semicolon_in_property comments.in test5.c
Expand All @@ -132,8 +133,8 @@ new_ec_test(octothorpe_comment_before_props comments.in test9.c
"^key=value[ \t\n\r]*$")

# test octothorpe comments ignored between properties
new_ec_test(octothorpe_comment_between_props comments.in test10.c
"^key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*$")
new_ec_test_multiline(octothorpe_comment_between_props_ML comments.in test10.c
"key1=value1[ \t]*[\n\r]+key2=value2[ \t\n\r]*")

# test octothorpe at end of property value are included in value
new_ec_test(octothorpe_in_property comments.in test11.c
Expand Down
31 changes: 16 additions & 15 deletions properties/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#
# Copyright (c) 2011-2012 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
Expand All @@ -26,18 +26,18 @@


# test tab_width default
new_ec_test(tab_width_default tab_width_default.in test.c
"^indent_style=space[ \t]*[\n\r]+indent_size=4[ \t]*[\n\r]+tab_width=4[\t\n\r]*$")
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]*")

# Tab_width should not be set to any value if indent_size is "tab" and
# tab_width is not set
new_ec_test(tab_width_default_indent_size_tab tab_width_default.in test2.c
"^indent_style=tab[ \t]*[\n\r]+indent_size=tab[ \t\n\r]*$")
new_ec_test_multiline(tab_width_default_indent_size_tab_ML tab_width_default.in test2.c
"indent_size=tab[ \t]*[\n\r]+indent_style=tab[ \t\n\r]*")

# Test indent_size default. When indent_style is "tab", indent_size defaults to
# "tab".
new_ec_test(indent_size_default indent_size_default.in test.c
"^indent_style=tab[ \t]*[\n\r]+indent_size=tab[ \t\n\r]*$")
new_ec_test_multiline(indent_size_default_ML indent_size_default.in test.c
"indent_size=tab[ \t]*[\n\r]+indent_style=tab[ \t\n\r]*")

# Test indent_size default. When indent_style is "tab", indent_size should have
# no default value for version prior than 0.9.0.
Expand All @@ -51,16 +51,17 @@ new_ec_test(indent_size_default_space indent_size_default.in test2.c

# Test indent_size default. When indent_style is "tab" and tab_width is set,
# indent_size should default to tab_width
new_ec_test(indent_size_default_with_tab_width indent_size_default.in test3.c
"^indent_style=tab[ \t]*[\n\r]+tab_width=2[ \t]*[\n\r]+indent_size=2[ \t\n\r]*$")
new_ec_test_multiline(indent_size_default_with_tab_width_ML
indent_size_default.in test3.c
"indent_size=2[ \t]*[\n\r]+indent_style=tab[ \t]*[\n\r]+tab_width=2[ \t\n\r]*")

# test that same property values are lowercased (v0.9.0 properties)
new_ec_test(lowercase_values1 lowercase_values.in test1.c
"^indent_style=space[ \t]*[\n\r]+end_of_line=crlf[ \t\n\r]*$")
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]*" )

# test that same property values are lowercased (v0.9.0 properties)
new_ec_test(lowercase_values2 lowercase_values.in test2.c
"^insert_final_newline=true[ \t]*[\n\r]+trim_trailing_whitespace=false[ \t]*[\n\r]+charset=utf-8[ \t\n\r]*$")
new_ec_test_multiline(lowercase_values2_ML lowercase_values.in test2.c
"charset=utf-8[ \t]*[\n\r]+insert_final_newline=true[ \t]*[\n\r]+trim_trailing_whitespace=false[ \t\n\r]*$")

# test that same property values are not lowercased
new_ec_test(lowercase_values3 lowercase_values.in test3.c
Expand Down

0 comments on commit 6b18aa9

Please sign in to comment.