diff options
author | Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> | 2022-01-10 17:06:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-10 17:06:42 +0000 |
commit | 7c3408d1a88a24c2db917ab48cb15d13ac683427 (patch) | |
tree | e21fda5496a80e7a9e9955a76025d1ad2c76c2ab | |
parent | Fix docstring on `add_account_data_for_user`. (#11716) (diff) | |
download | synapse-7c3408d1a88a24c2db917ab48cb15d13ac683427.tar.xz |
Document the `SYNAPSE_TEST_PERSIST_SQLITE_DB` unit test env var (#11715)
-rw-r--r-- | changelog.d/11715.doc | 1 | ||||
-rw-r--r-- | docs/development/contributing_guide.md | 21 |
2 files changed, 22 insertions, 0 deletions
diff --git a/changelog.d/11715.doc b/changelog.d/11715.doc new file mode 100644 index 0000000000..32b7c10b0b --- /dev/null +++ b/changelog.d/11715.doc @@ -0,0 +1 @@ +Document the new `SYNAPSE_TEST_PERSIST_SQLITE_DB` environment variable in the contributing guide. diff --git a/docs/development/contributing_guide.md b/docs/development/contributing_guide.md index abdb808438..121f7c0687 100644 --- a/docs/development/contributing_guide.md +++ b/docs/development/contributing_guide.md @@ -169,6 +169,27 @@ To increase the log level for the tests, set `SYNAPSE_TEST_LOG_LEVEL`: SYNAPSE_TEST_LOG_LEVEL=DEBUG trial tests ``` +By default, tests will use an in-memory SQLite database for test data. For additional +help with debugging, one can use an on-disk SQLite database file instead, in order to +review database state during and after running tests. This can be done by setting +the `SYNAPSE_TEST_PERSIST_SQLITE_DB` environment variable. Doing so will cause the +database state to be stored in a file named `test.db` under the trial process' +working directory. Typically, this ends up being `_trial_temp/test.db`. For example: + +```sh +SYNAPSE_TEST_PERSIST_SQLITE_DB=1 trial tests +``` + +The database file can then be inspected with: + +```sh +sqlite3 _trial_temp/test.db +``` + +Note that the database file is cleared at the beginning of each test run. Thus it +will always only contain the data generated by the *last run test*. Though generally +when debugging, one is only running a single test anyway. + ### Running tests under PostgreSQL Invoking `trial` as above will use an in-memory SQLite database. This is great for |