Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

properties -> pairs #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ endif()
function(new_ec_test name ec_file src_file regex)
add_test(NAME ${name} COMMAND ${EDITORCONFIG_CMD} -f ${ec_file}
"${CMAKE_CURRENT_SOURCE_DIR}/${src_file}")
set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}")
set_tests_pairs(${name} PAIRS PASS_REGULAR_EXPRESSION "${regex}")
endfunction()

# A test that requires a version specified
function(new_ec_test_version name ec_file src_file regex version)
add_test(NAME ${name} COMMAND ${EDITORCONFIG_CMD} -b ${version} -f ${ec_file}
"${CMAKE_CURRENT_SOURCE_DIR}/${src_file}")
set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}")
set_tests_pairs(${name} PAIRS PASS_REGULAR_EXPRESSION "${regex}")
endfunction()

# A test that requires the full path to the EditorConfig files
function(new_ec_test_full_ec_file_path name ec_file src_file regex)
add_test(NAME ${name} COMMAND ${EDITORCONFIG_CMD} -f ${ec_file} ${src_file})
set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${regex}")
set_tests_pairs(${name} PAIRS PASS_REGULAR_EXPRESSION "${regex}")
endfunction()

# A test that returns multiple lines of output. CAUTION: filenames used in
Expand All @@ -94,7 +94,7 @@ function(new_ec_test_multiline name ec_file src_file regex)
"-P" "${tests_cmakelists_dir}/cmake/ec_sort.cmake")
endif()

set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION
set_tests_pairs(${name} PAIRS PASS_REGULAR_EXPRESSION
"^[\r\n]*${regex}$")
# Permit leading \n's because I can't always get rid of them using
# only CMake-provided facilities.
Expand All @@ -111,7 +111,7 @@ function(new_ec_cli_test)

# Add test
add_test(NAME ${P_NAME} COMMAND ${EDITORCONFIG_CMD} ${P_ARGS})
set_tests_properties(${name} PROPERTIES PASS_REGULAR_EXPRESSION "${P_MATCH}")
set_tests_pairs(${name} PAIRS PASS_REGULAR_EXPRESSION "${P_MATCH}")

endfunction()

Expand All @@ -120,7 +120,7 @@ add_subdirectory(meta)

# Then test the core.
add_subdirectory(glob)
add_subdirectory(properties)
add_subdirectory(pairs)
add_subdirectory(parser)
add_subdirectory(filetree)
add_subdirectory(cli)
2 changes: 1 addition & 1 deletion filetree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ 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
# Test the unset value with various common keys
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_multiline(unset_indent_size_ML unset.in unset/indent_size.txt
Expand Down
2 changes: 1 addition & 1 deletion meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ 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
set_tests_pairs(meta_runandsort PAIRS PASS_REGULAR_EXPRESSION
"^[\r\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

Expand Down
12 changes: 6 additions & 6 deletions properties/CMakeLists.txt → pairs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ 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)
# test that same pair values are lowercased (v0.9.0 pairs)
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)
# test that same pair values are lowercased (v0.9.0 pairs)
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
# test that same pair values are not lowercased
new_ec_test(lowercase_values3 lowercase_values.in test3.c
"^test_property=TestValue[ \t\n\r]*$")
"^test_key=TestValue[ \t\n\r]*$")

# test that all property names are lowercased
# test that all pair keys are lowercased
new_ec_test(lowercase_names lowercase_names.in test.c
"^testproperty=testvalue[ \t\n\r]*$")
"^testkey=testvalue[ \t\n\r]*$")
File renamed without changes.
6 changes: 6 additions & 0 deletions pairs/lowercase_names.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; test that pair keys are lowercased

root = true

[test.c]
TestKey = testvalue
4 changes: 2 additions & 2 deletions properties/lowercase_values.in → pairs/lowercase_values.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
; test property name lowercasing
; test pair key lowercasing

root = true

Expand All @@ -12,4 +12,4 @@ trim_trailing_whitespace = False
charset = UTF-8

[test3.c]
test_property = TestValue
test_key = TestValue
File renamed without changes.
38 changes: 19 additions & 19 deletions parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ new_ec_test_multiline(basic_cascade_ML basic.in b.b "option1=c[ \t]*[\n\r]+optio

# Tests for whitespace parsing

# test no whitespaces in property assignment
# test no whitespaces in pair assignment
new_ec_test(no_whitespace whitespace.in test1.c "^key=value[ \t\n\r]*$")

# test single spaces around equals sign
Expand All @@ -43,16 +43,16 @@ new_ec_test(single_spaces_around_equals whitespace.in test2.c
new_ec_test(multiple_spaces_around_equals whitespace.in test3.c
"^key=value[ \t\n\r]*$")

# test spaces before property name
new_ec_test(spaces_before_property_name whitespace.in test4.c
# test spaces before pair key
new_ec_test(spaces_before_pair_key whitespace.in test4.c
"^key=value[ \t\n\r]*$")

# test spaces before after property value
new_ec_test(spaces_after_property_value whitespace.in test5.c
# test spaces before after pair value
new_ec_test(spaces_after_pair_value whitespace.in test5.c
"^key=value[ \t\n\r]*$")

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

# test spaces in section name
Expand All @@ -66,37 +66,37 @@ new_ec_test(spaces_before_section_name whitespace.in test8.c
# test spaces after section name
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_multiline(spaces_before_middle_property_ML whitespace.in test10.c
# test spaces at beginning of line between pairs
new_ec_test_multiline(spaces_before_middle_pair_ML whitespace.in test10.c
"key1=value1[ \t]*[\n\r]+key2=value2[ \t]*[\n\r]+key3=value3[ \t\n\r]*")

# Tests for comment parsing

# test comments ignored before properties
# test comments ignored before pairs
new_ec_test(comment_before_props comments.in test3.c
"^key=value[ \t\n\r]*$")

# test comments ignored between properties
# test comments ignored between pairs
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
# test semicolons at end of pair value are included in value
new_ec_test(semicolon_in_pair_value comments.in test5.c
"^key=value; not comment[ \t\n\r]*$")

# test escaped semicolons are included in section names
new_ec_test(escaped_semicolon_in_section comments.in "test;.c"
"^key=value[ \t\n\r]*$")

# test octothorpe comments ignored before properties
# test octothorpe comments ignored before pairs
new_ec_test(octothorpe_comment_before_props comments.in test9.c
"^key=value[ \t\n\r]*$")

# test octothorpe comments ignored between properties
# test octothorpe comments ignored between pairs
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
# test octothorpe at end of pair value are included in value
new_ec_test(octothorpe_in_value comments.in test11.c
"^key=value# not comment[ \t\n\r]*$")

Expand All @@ -111,10 +111,10 @@ new_ec_test(bom_at_head bom.in "a.c" "^key=value[ \t\n\r]*$")
new_ec_test(crlf_linesep crlf.in "a.c" "^key=value[ \t\n\r]*$")


# Test max property name and values
new_ec_test(max_property_name limits.in test1
# Test max pair key and values
new_ec_test(max_pair_key limits.in test1
"^00000000000000000000000000000000000000000000000001=50[ \t\n\r]*$")
new_ec_test(max_property_value limits.in test2
new_ec_test(max_pair_value limits.in test2
"^k255=000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001[ \t\n\r]*$")

# Test max section names
Expand Down
8 changes: 4 additions & 4 deletions parser/comments.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
root = true

[test3.c]
; Comment before properties ignored
; Comment before key-value pair ignored
key=value

[test4.c]
key1=value1
; Comment between properties ignored
; Comment between key-value pairs ignored
key2=value2

; Semicolon at end of value read as part of value
Expand All @@ -24,12 +24,12 @@ key=value \; not comment
key=value

[test9.c]
# Comment before properties ignored
# Comment before key-value pair ignored
key=value

[test10.c]
key1=value1
# Comment between properties ignored
# Comment between key-value pairs ignored
key2=value2

# Octothorpe at end of value read as part of value
Expand Down
8 changes: 4 additions & 4 deletions parser/whitespace.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ key = value
[test3.c]
key = value

; spaces before property name
; spaces before pair key
[test4.c]
key=value

; spaces after property value
; spaces after pair value
[test5.c]
key=value

; blank lines between properties
; blank lines between key-value pairs
[test6.c]

key1=value1
Expand All @@ -41,7 +41,7 @@ key=value
[test9.c]
key=value

; spacing before middle property
; spacing before middle key-value pair
[test10.c]
key1=value1
key2=value2
Expand Down
6 changes: 0 additions & 6 deletions properties/lowercase_names.in

This file was deleted.