kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'bugfix/ldgen_allow_more_characters_sections_entries' into 'master'
ldgen: allow more characters in `sections` fragment `entries` See merge request espressif/esp-idf!10956pull/4512/merge
commit
f7de809f31
tools/ldgen
|
@ -31,6 +31,7 @@ from pyparsing import Optional
|
|||
from pyparsing import originalTextFor
|
||||
from pyparsing import Forward
|
||||
from pyparsing import indentedBlock
|
||||
from pyparsing import Combine
|
||||
from collections import namedtuple
|
||||
import abc
|
||||
|
||||
|
@ -216,8 +217,14 @@ class Fragment():
|
|||
|
||||
class Sections(Fragment):
|
||||
|
||||
# Unless quoted, symbol names start with a letter, underscore, or point
|
||||
# and may include any letters, underscores, digits, points, and hyphens.
|
||||
GNU_LD_SYMBOLS = Word(alphas + "_.", alphanums + "._-")
|
||||
|
||||
entries_grammar = Combine(GNU_LD_SYMBOLS + Optional("+"))
|
||||
|
||||
grammars = {
|
||||
"entries": KeyGrammar(Word(alphanums + "+.").setResultsName("section"), 1, None, True)
|
||||
"entries": KeyGrammar(entries_grammar.setResultsName("section"), 1, None, True)
|
||||
}
|
||||
|
||||
"""
|
||||
|
|
|
@ -523,6 +523,59 @@ entries:
|
|||
with self.assertRaises(ParseFatalException):
|
||||
FragmentFile(test_fragment, self.sdkconfig)
|
||||
|
||||
def test_entries_grammar(self):
|
||||
|
||||
test_fragment = self.create_fragment_file(u"""
|
||||
[sections:test]
|
||||
entries:
|
||||
_valid1
|
||||
valid2.
|
||||
.valid3_-
|
||||
""")
|
||||
|
||||
fragment_file = FragmentFile(test_fragment, self.sdkconfig)
|
||||
self.assertEqual(fragment_file.fragments[0].entries,
|
||||
{"_valid1", "valid2.", ".valid3_-"})
|
||||
|
||||
# invalid starting char
|
||||
test_fragment = self.create_fragment_file(u"""
|
||||
[sections:test]
|
||||
entries:
|
||||
1invalid
|
||||
""")
|
||||
|
||||
with self.assertRaises(ParseException):
|
||||
FragmentFile(test_fragment, self.sdkconfig)
|
||||
|
||||
test_fragment = self.create_fragment_file(u"""
|
||||
[sections:test]
|
||||
entries:
|
||||
-invalid
|
||||
""")
|
||||
|
||||
with self.assertRaises(ParseException):
|
||||
FragmentFile(test_fragment, self.sdkconfig)
|
||||
|
||||
# + notation
|
||||
test_fragment = self.create_fragment_file(u"""
|
||||
[sections:test]
|
||||
entries:
|
||||
valid+
|
||||
""")
|
||||
|
||||
fragment_file = FragmentFile(test_fragment, self.sdkconfig)
|
||||
self.assertEqual(fragment_file.fragments[0].entries,
|
||||
{"valid+"})
|
||||
|
||||
test_fragment = self.create_fragment_file(u"""
|
||||
[sections:test]
|
||||
entries:
|
||||
inva+lid+
|
||||
""")
|
||||
|
||||
with self.assertRaises(ParseFatalException):
|
||||
FragmentFile(test_fragment, self.sdkconfig)
|
||||
|
||||
|
||||
class SchemeTest(FragmentTest):
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue