Skip to content

Commit

Permalink
Merge pull request #1603 from buildtesters/change_docs_build_unique_dir
Browse files Browse the repository at this point in the history
Use unique directory when performing documentation build
  • Loading branch information
shahzebsiddiqui authored Aug 29, 2023
2 parents 9d67477 + 9a024ed commit 97bdd6c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions buildtest/cli/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,8 @@ def print_config_show():
"buildtest config profiles list", "Listing all profiles from configuration file"
)
table.add_row(
"buildtest config profiles remove",
"Remove an existing profile from configuration file",
"buildtest config profiles remove python",
"Remove a profile 'python' from configuration file",
)
console.print(table)

Expand Down
2 changes: 0 additions & 2 deletions buildtest/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import os
import pwd
import shutil

from rich.console import Console

Expand Down Expand Up @@ -36,7 +35,6 @@
if ci_dir:
VAR_DIR = os.path.join(ci_dir, "var")
settings_file = os.path.join(ci_dir, "config.yml")
shutil.copyfile(DEFAULT_SETTINGS_FILE, settings_file)
DEFAULT_SETTINGS_FILE = settings_file


Expand Down
3 changes: 3 additions & 0 deletions buildtest/tools/unittests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
BUILDTEST_ROOT,
BUILDTEST_UNITTEST_ROOT,
BUILDTEST_USER_HOME,
DEFAULT_SETTINGS_FILE,
VAR_DIR,
console,
)
Expand All @@ -39,6 +40,8 @@ def run_unit_tests(pytestopts=None, sourcefiles=None, enable_coverage=False):
)

os.environ["BUILDTEST_CI_DIR"] = tempfile.mkdtemp()
settings_file = os.path.join(os.environ["BUILDTEST_CI_DIR"], "config.yml")
shutil.copyfile(DEFAULT_SETTINGS_FILE, settings_file)

console.rule("Running buildtest unit tests")
console.print("BUILDTEST_CI_DIR", os.getenv("BUILDTEST_CI_DIR"))
Expand Down
9 changes: 8 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,27 @@
import os
import shutil
import sys
import tempfile

here = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, here)
from buildtest import BUILDTEST_COPYRIGHT, BUILDTEST_VERSION
from buildtest.cli.buildspec import BuildspecCache
from buildtest.config import SiteConfiguration
from buildtest.defaults import BUILDTEST_ROOT, VAR_DIR
from buildtest.defaults import BUILDTEST_ROOT, DEFAULT_SETTINGS_FILE, VAR_DIR
from buildtest.utils.file import is_dir

# set BUILDTEST_ROOT environment that is generally set by 'source setup.sh'
os.environ["BUILDTEST_ROOT"] = here
# add $BUILDTEST_ROOT/bin to $PATH to reference 'buildtest' command in docs
os.environ["PATH"] += "%s%s" % (os.pathsep, os.path.join(here, "bin"))

os.environ["BUILDTEST_CI_DIR"] = tempfile.mkdtemp()
print(f"BUILDTEST_CI_DIR: {os.environ['BUILDTEST_CI_DIR']}")

settings_file = os.path.join(os.environ["BUILDTEST_CI_DIR"], "config.yml")
shutil.copyfile(DEFAULT_SETTINGS_FILE, settings_file)

# remove $BUILDTEST_ROOT/var which writes variable data
if is_dir(VAR_DIR):
shutil.rmtree(VAR_DIR)
Expand Down
7 changes: 3 additions & 4 deletions docs/contributing/regression_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@ the script via python
:shell:


The `pytest.ini <https://github.com/buildtesters/buildtest/blob/devel/pytest.ini>`_
found in top-level folder defines pytest configuration for running the unit tests. Some of the unit tests are
assigned a `marker <https://docs.pytest.org/en/6.2.x/example/markers.html>`_ which allows one to run a group of test together. You
can find all markers by running ``pytest --markers``.
The pytest configuration is defined in `pyproject.toml <https://github.com/buildtesters/buildtest/blob/devel/pyproject.toml>`_
found in top-level folder. Some of the unit tests are assigned a `marker <https://docs.pytest.org/en/6.2.x/example/markers.html>`_
which allows one to run a group of test together. You can find all markers by running ``pytest --markers``.

If you want to run all tests with ``schema`` marker you can do the following::

Expand Down
4 changes: 2 additions & 2 deletions docs/gettingstarted/buildingtest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ with a profile called **python-tests**

.. dropdown:: buildtest configuration with profile

.. command-output:: cat $BUILDTEST_ROOT/buildtest/settings/config.yml
:shell:
.. command-output:: buildtest config view


Next, let's build the tests via newly created profile and take note that it will run all tests with tag `python`

Expand Down

0 comments on commit 97bdd6c

Please sign in to comment.