sqlite: convert to new stand-alone test process (#37722)

This commit is contained in:
Tamara Dahlgren 2023-05-29 04:59:23 -07:00 committed by GitHub
parent 8790efbcfe
commit 577df6f498
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -220,53 +220,28 @@ def build_libsqlitefunctions(self):
) )
install(libraryname, self.prefix.lib) install(libraryname, self.prefix.lib)
def _test_example(self): def test_example(self):
"""Ensure a sequence of commands on example db are successful.""" """check example table dump"""
test_data_dir = self.test_suite.current_test_data_dir test_data_dir = self.test_suite.current_test_data_dir
db_filename = test_data_dir.join("packages.db") db_filename = test_data_dir.join("packages.db")
exe = "sqlite3"
# Ensure the database only contains one table # Ensure the database only contains one table
expected = "packages" sqlite3 = which(self.prefix.bin.sqlite3)
reason = 'test: ensuring only table is "{0}"'.format(expected) out = sqlite3(db_filename, ".tables", output=str.split, error=str.split)
self.run_test( assert "packages" in out
exe,
[db_filename, ".tables"],
expected,
installed=True,
purpose=reason,
skip_missing=False,
)
# Ensure the database dump matches expectations, where special # Ensure the database dump matches expectations, where special
# characters are replaced with spaces in the expected and actual # characters are replaced with spaces in the expected and actual
# output to avoid pattern errors. # output to avoid pattern errors.
reason = "test: checking dump output"
expected = get_escaped_text_output(test_data_dir.join("dump.out")) expected = get_escaped_text_output(test_data_dir.join("dump.out"))
self.run_test( out = sqlite3(db_filename, ".dump", output=str.split, error=str.split)
exe, check_outputs(expected, out)
[db_filename, ".dump"],
expected,
installed=True,
purpose=reason,
skip_missing=False,
)
def _test_version(self): def test_version(self):
"""Perform version check on the installed package.""" """ensure version is expected"""
exe = "sqlite3"
vers_str = str(self.spec.version) vers_str = str(self.spec.version)
reason = "test: ensuring version of {0} is {1}".format(exe, vers_str) sqlite3 = which(self.prefix.bin.sqlite3)
self.run_test( out = sqlite3("-version", output=str.split, error=str.split)
exe, "-version", vers_str, installed=True, purpose=reason, skip_missing=False assert vers_str in out
)
def test(self):
"""Perform smoke tests on the installed package."""
# Perform a simple version check
self._test_version()
# Run a sequence of operations
self._test_example()