aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/run_tests/sanity
diff options
context:
space:
mode:
authorGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2016-02-24 10:26:29 -0800
committerGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2016-02-24 10:26:29 -0800
commitd3a7b609179644138ca1f68457f92cbd73bdeb53 (patch)
tree0312e7ba0b6f346d602223b27373b64b0f7dc75b /tools/run_tests/sanity
parent91edc13bf8a83dd024f9ce4e0ad2246202545a38 (diff)
parent4ea4599a50abb9188927846dc9f5449dbf5e8537 (diff)
Merge pull request #5365 from ctiller/naming-crisis
Add a sanity test to ensure that name aliasing rules are obeyed
Diffstat (limited to 'tools/run_tests/sanity')
-rwxr-xr-xtools/run_tests/sanity/check_sources_and_headers.py54
1 files changed, 36 insertions, 18 deletions
diff --git a/tools/run_tests/sanity/check_sources_and_headers.py b/tools/run_tests/sanity/check_sources_and_headers.py
index 3974af0032..44dc49bb06 100755
--- a/tools/run_tests/sanity/check_sources_and_headers.py
+++ b/tools/run_tests/sanity/check_sources_and_headers.py
@@ -59,25 +59,43 @@ def target_has_header(target, name):
return True
return False
+def produces_object(name):
+ return os.path.splitext(name)[1] in ['.c', '.cc']
+
+obj_producer_to_source = {'c': {}, 'c++': {}, 'csharp': {}}
+
errors = 0
for target in js:
- for fn in target['src']:
- with open(os.path.join(root, fn)) as f:
- src = f.read().splitlines()
- for line in src:
- m = re_inc1.match(line)
- if m:
- if not target_has_header(target, m.group(1)):
- print (
- 'target %s (%s) does not name header %s as a dependency' % (
- target['name'], fn, m.group(1)))
- errors += 1
- m = re_inc2.match(line)
- if m:
- if not target_has_header(target, 'include/' + m.group(1)):
- print (
- 'target %s (%s) does not name header %s as a dependency' % (
- target['name'], fn, m.group(1)))
- errors += 1
+ if not target['third_party']:
+ for fn in target['src']:
+ with open(os.path.join(root, fn)) as f:
+ src = f.read().splitlines()
+ for line in src:
+ m = re_inc1.match(line)
+ if m:
+ if not target_has_header(target, m.group(1)):
+ print (
+ 'target %s (%s) does not name header %s as a dependency' % (
+ target['name'], fn, m.group(1)))
+ errors += 1
+ m = re_inc2.match(line)
+ if m:
+ if not target_has_header(target, 'include/' + m.group(1)):
+ print (
+ 'target %s (%s) does not name header %s as a dependency' % (
+ target['name'], fn, m.group(1)))
+ errors += 1
+ if target['type'] == 'lib':
+ for fn in target['src']:
+ language = target['language']
+ if produces_object(fn):
+ obj_base = os.path.splitext(os.path.basename(fn))[0]
+ if obj_base in obj_producer_to_source[language]:
+ if obj_producer_to_source[language][obj_base] != fn:
+ print (
+ 'target %s (%s) produces an aliased object file with %s' % (
+ target['name'], fn, obj_producer_to_source[language][obj_base]))
+ else:
+ obj_producer_to_source[language][obj_base] = fn
assert errors == 0