tests/bugfix: Fix and clean up copied example checks (#23276)

This commit is contained in:
Tamara Dahlgren 2021-05-11 10:38:40 -07:00 committed by GitHub
parent 066d33b4b3
commit 00fe243e9c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -949,14 +949,29 @@ def _test_check_versions(self):
self.run_test(exe, '--version', expected, installed=True, self.run_test(exe, '--version', expected, installed=True,
purpose=purpose, skip_missing=True) purpose=purpose, skip_missing=True)
def _test_examples(self): def _test_build_examples(self):
# First build the examples # Build the examples copied during installation and return "status"
self.run_test('make', ['all'], [], reason = 'test: ensuring ability to build the examples'
purpose='test: ensuring ability to build the examples', return self.run_test('make', ['all'], [],
purpose=reason,
work_dir=join_path(self.install_test_root, work_dir=join_path(self.install_test_root,
self.extra_install_tests)) self.extra_install_tests))
# Now run those with known results def _test_clean_examples(self):
# Clean up any example build files
reason = 'test: ensuring copied examples cleaned up'
return self.run_test('make', ['clean'], [],
purpose=reason,
work_dir=join_path(self.install_test_root,
self.extra_install_tests))
def _test_examples(self):
# First ensure can build copied examples
if not self._test_build_examples():
self._test_clean_examples()
return
# Now run examples with known, simple-to-verify results
have_spml = self.spec.satisfies('@2.0.0:2.1.6') have_spml = self.spec.satisfies('@2.0.0:2.1.6')
hello_world = (['Hello, world', 'I am', '0 of', '1'], 0) hello_world = (['Hello, world', 'I am', '0 of', '1'], 0)
@ -995,10 +1010,15 @@ def _test_examples(self):
} }
for exe in checks: for exe in checks:
expected = checks[exe] expected, status = checks[exe]
reason = 'test: checking example {0} output'.format(exe) reason = 'test: checking {0} example output and status ({1})' \
self.run_test(exe, [], expected, 0, installed=True, .format(exe, status)
purpose=reason, skip_missing=True) self.run_test(exe, [], expected, status, installed=False,
purpose=reason, skip_missing=True,
work_dir=join_path(self.install_test_root,
self.extra_install_tests))
self._test_clean_examples()
def test(self): def test(self):
"""Perform smoke tests on the installed package.""" """Perform smoke tests on the installed package."""