-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
One of the main functionality that is still untested is the 'tildeexpand'.
- Loading branch information
1 parent
242d9ff
commit c973a13
Showing
28 changed files
with
161 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Tests for the library `liblinuxcncini`. | ||
|
||
This is the library created from the files `src/libnml/inifile/inifile.*`. To | ||
simplify the testing we utilize the application `inivar`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Test the INI parser with regards to comments, both inline and on it's own line. | ||
|
||
After 2.7.x, the INI parser in LinuxCNC does not support inline comments. | ||
See: https://github.com/LinuxCNC/linuxcnc/issues/991 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
value1 | ||
value2 ; inline comment | ||
value3 | ||
value4 # another inline comment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
inivar -ini with_comments.ini -var key1 | ||
inivar -ini with_comments.ini -var key2 | ||
inivar -ini with_comments.ini -var key3 | ||
inivar -ini with_comments.ini -var key4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
; This is a comment | ||
[section1] | ||
key1=value1 | ||
; Another comment | ||
key2=value2 ; inline comment | ||
# different comment style | ||
key3=value3 | ||
key4=value4 # another inline comment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[section1] | ||
key1=value1 | ||
key2=value2 \ | ||
value3 \ | ||
value4 \ | ||
value5 | ||
key3=value6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
value2 value3 value4 value5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
inivar -ini continuation_lines.ini -var key2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[section1] | ||
key1=value1 | ||
key1=value2 | ||
|
||
[section2] | ||
key1=value3 | ||
key1=value4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
value1 | ||
value1 | ||
value4 | ||
value3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/bash | ||
|
||
inivar -ini duplicated_keys.ini -var key1 | ||
inivar -ini duplicated_keys.ini -var key1 -sec section1 -num 1 | ||
inivar -ini duplicated_keys.ini -var key1 -sec section2 -num 2 | ||
inivar -ini duplicated_keys.ini -var key1 -num 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
The INI parser in LinuxCNC handles UNIX line endings, '\n' and DOS '\r\n', with | ||
a warning. The parser aborts when it encounters classic MAC OS line endings '\r'. | ||
|
||
The INI files is created in the test script, since several tools automatically | ||
fixes the line endings. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
value1 | ||
value1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# Manually create INI files with different line endings. | ||
lf="[section1]\nkey1=value1\n" | ||
cr="[section1]\rkey1=value1\r" | ||
crlf="[section1]\r\nkey1=value1\r\n" | ||
|
||
echo -e "$lf" > "lf.ini" | ||
echo -e "$cr" > "cr.ini" | ||
echo -e "$crlf" > "crlf.ini" | ||
|
||
inivar -ini lf.ini -var key1 # Should be successful. | ||
inivar -ini cr.ini -var key1 # Should fail. | ||
inivar -ini crlf.ini -var key1 # Should be successful. | ||
|
||
rm -f lf.ini cr.ini crlf.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
value1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
key1=value1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[section1] | ||
key1= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
inivar -ini missing_section.ini -sec section1 -var key1 | ||
inivar -ini missing_value.ini -var key1 | ||
inivar -ini missing_section.ini -var key1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
value1 | ||
value2 | ||
value3 | ||
Did not find missing value | ||
a long value | ||
0.000001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/python3 | ||
|
||
import linuxcnc | ||
|
||
inifile = linuxcnc.ini("values.ini") | ||
|
||
missing_value = inifile.find("section1", "missing") | ||
value_with_space = inifile.find("section1", "key3") | ||
numbered_value = inifile.find("section1", "number") | ||
list_of_values = inifile.findall("section2", "key1") | ||
|
||
for value in list_of_values: | ||
print(value) | ||
if missing_value is None: | ||
print("Did not find missing value") | ||
print(value_with_space) | ||
print(numbered_value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[section1] | ||
key1=value1 | ||
key2=value 2 | ||
key3 = a long value | ||
a long key = value4 | ||
number = 0.000001 | ||
|
||
[section2] | ||
key1=value1 | ||
key1=value2 | ||
key1=value3 | ||
key4=value4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
value1 | ||
value 2 | ||
a long value | ||
value4 | ||
0.000001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
inivar -ini values.ini -var key1 | ||
inivar -ini values.ini -var key2 | ||
inivar -ini values.ini -var key3 | ||
inivar -ini values.ini -var "a long key" | ||
inivar -ini values.ini -var number |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[section1] | ||
key1=value1 | ||
key2=value 2 | ||
key3 = a long value | ||
a long key = value4 | ||
number = 0.000001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
value1 | ||
value1 | ||
value1 | ||
value1 | ||
value2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[section1] | ||
key1=value1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[section1] | ||
key1 = value1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Manually create INI file with trailing whitespace. | ||
ini_content="[section1] \nkey1=value1\t\nkey2=value2 \n" | ||
echo -e "$ini_content" > "trailing_whitespace.ini" | ||
|
||
inivar -ini leading_whitespace.ini -var key1 | ||
inivar -ini leading_whitespace.ini -sec section1 -var key1 | ||
inivar -ini space_between_equal.ini -var key1 | ||
inivar -ini trailing_whitespace.ini -var key1 | ||
inivar -ini trailing_whitespace.ini -var key2 | ||
|
||
rm -f trailing_whitespace.ini |