@@ -49,27 +49,26 @@ def __str__(self):
49
49
50
50
# Checks if the line has a compile annotation.
51
51
# FIXME: Add match for target
52
- re_compile = re .compile ('[{][ ]*dg-do[ ]*compile[ ]*(.*)[}]' )
52
+ re_compile = re .compile ('[{][ ]*dg-do[ ]*compile[ ]*(.*)[ ]*[ }]' )
53
53
54
54
# Checks if the line has a link annotation.
55
- re_link = re .compile ('[{][ ]*dg-do[ ]*link[ ]+(.*)[}]' )
55
+ re_link = re .compile ('[{][ ]*dg-do[ ]*link[ ]+(.*)[ ]*[ }]' )
56
56
57
57
# Checks if the line has a run annotation or lto-run annotation.
58
58
# FIXME: Add match for target
59
- re_run = re .compile ('[{][ ]*dg-(lto-)?do[ ]*run[ ]+(.*)[}]' )
59
+ re_run = re .compile ('[{][ ]*dg-(lto-)?do[ ]*run[ ]+(.*)[ ]*[ }]' )
60
60
61
61
# Checks if the line has an additional-sources annotation.
62
- re_sources = re .compile ('[{][ ]*dg-additional-sources[ ]*["]?([^"])["]? [ ]*[}]' )
62
+ re_sources = re .compile ('[{][ ]*dg-additional-sources[ ]*(.+) [ ]*[}]' )
63
63
64
64
# Checks if the line has a dg-compile-aux-modules annotation.
65
- re_aux_modules = re .compile (
66
- '[{][ ]*dg-compile-aux-modules[ ]*["]?([^"])["]?[}]'
67
- )
65
+ re_aux_modules = re .compile ('[{][ ]*dg-compile-aux-modules[ ]*(.+)[ ]*[}]' )
68
66
69
67
# Checks if the line has an options or additional-options annotation. The
70
68
# option may have an optional target.
71
69
re_options = re .compile (
72
- '[{][ ]*dg-(additional-)?options[ ]*["]?([^\" ]*)["]?[ ]*[}][ ]*([{][ ]*target[ ]*(.+)?[ ][}])?'
70
+ '[{][ ]*dg-(additional-)?options[ ]*(.+)[ ]*[}][ ]*'
71
+ '([{][ ]*target[ ]*(.+)?[ ]*[}])?'
73
72
)
74
73
75
74
# Checks if the line has a shouldfail annotation.
@@ -122,6 +121,18 @@ def get_subdirs(gfortran):
122
121
subdirs .extend ([os .path .join (root , d ) for d in dirs ])
123
122
return subdirs
124
123
124
+ # Strip any leading and trailing whitespace from the string as well as any
125
+ # optional quotes around the string. Then split the string on whitespace and
126
+ # return the resulting list.
127
+ # str -> list[str]
128
+ def qsplit (s ):
129
+ s = s .strip ()
130
+ if s .startswith ('"' ):
131
+ s = s [1 :]
132
+ if s .endswith ('"' ):
133
+ s = s [:- 1 ]
134
+ return s .split ()
135
+
125
136
# Try to match the line with the regex. If the line matches, add the match
126
137
# object to the MOUT list and return True. Otherwise, leave the MOUT list
127
138
# unchanged and return False.
@@ -152,19 +163,18 @@ def main():
152
163
for filename in files :
153
164
for l in get_lines (filename ):
154
165
mout = []
155
- if try_match (re_sources , l , mout ):
156
- m = mout [0 ]
157
- d = os .path .dirname (filename )
158
- for src in m [1 ].split ():
159
- dependencies .add (os .path .join (d , src ))
160
- print (dependencies )
161
- return 0
166
+ if try_match (re_sources , l , mout ) or \
167
+ try_match (re_aux_modules , l , mout ):
168
+ for m in mout :
169
+ for src in qsplit (m [1 ]):
170
+ dependencies .add (src )
162
171
163
172
tests = []
164
173
for f in files :
165
- if f in dependencies :
166
- continue
167
174
filename = os .path .basename (f )
175
+ if filename in dependencies :
176
+ continue
177
+
168
178
kind = None
169
179
sources = [filename ]
170
180
options = []
@@ -190,35 +200,28 @@ def main():
190
200
elif try_match (re_sources , l , mout ) or \
191
201
try_match (re_aux_modules , l , mout ):
192
202
m = mout [0 ]
193
- sources .extend (m [1 ]. split ( ))
203
+ sources .extend (qsplit ( m [1 ]))
194
204
elif try_match (re_options , l , mout ):
195
205
m = mout [0 ]
196
- options .extend (m [2 ]. split ( ))
206
+ options .extend (qsplit ( m [2 ]))
197
207
# TODO: Handle the optional target.
208
+
209
+ fmt = ' WARNING: {} without action annotation: {}'
198
210
if kind :
199
211
test = Test (kind , sources , options , targets , expect_error )
200
212
tests .append (test )
201
213
elif len (sources ) > 1 :
202
- print (
203
- ' WARNING: Additional sources without action annotation:' ,
204
- filename
205
- )
214
+ print (fmt .format ('Additional sources' , filename ))
206
215
elif len (options ) > 1 :
207
- print (
208
- ' WARNING: Compile options without action annotation:' ,
209
- filename
210
- )
216
+ print (fmt .format ('Compile options' , filename ))
211
217
elif expect_error :
212
- print (
213
- ' WARNING: Expect error set without action annotation' ,
214
- filename
215
- )
218
+ print (fmt .format ('Expect error' , filename ))
216
219
else :
217
220
pass
218
221
# print(' WARNING: No action annotation:', filename)
219
222
for t in tests :
220
- print (str (t ))
221
- # print(' ', len(tests))
223
+ print (' ' , str (t ))
224
+ print (' ' , len (tests ))
222
225
223
226
if __name__ == '__main__' :
224
227
exit (main ())
0 commit comments