Skip to content

SphinxTestApp builds in _build, not separated build folder #9524

@adamgranthendry

Description

@adamgranthendry

Describe the bug

When running sphinx-quickstart, users may choose to put build files in a folder build separate from source. However, when running unit tests, SphinxTestApp automatically builds in source/_build, which creates two sets of build files. This is evident from the source:

class SphinxTestApp(application.Sphinx):
    """
    A subclass of :class:`Sphinx` that runs on the test root, with some
    better default values for the initialization parameters.
    """
    _status: StringIO = None
    _warning: StringIO = None

    def __init__(self, buildername: str = 'html', srcdir: path = None, freshenv: bool = False,
                 confoverrides: Dict = None, status: IO = None, warning: IO = None,
                 tags: List[str] = None, docutilsconf: str = None, parallel: int = 0) -> None:

        if docutilsconf is not None:
            (srcdir / 'docutils.conf').write_text(docutilsconf)

        builddir = srcdir / '_build'

How to Reproduce

> sphinx-quickstart
...
Enter the root path for documentation.
> Root path for the documentation [.]:

You have two options for placing the build directory for Sphinx output.
Either, you use a directory "_build" within the root path, or you separate
"source" and "build" directories within the root path.
> Separate source and build directories (y/n) [n]: y
...

Then, when running a test, files are built to source/_build instead of the desired build folder.

Expected behavior

sphinx uses the environment variable ${BUILDDIR} (written out to Makefile and make.bat) set when running sphinx-quickstart as the folder to put build files in.

Your project

N/A

Screenshots

image

OS

Windows 10 Professional x64, Build 1909

Python version

3.8.10

Sphinx version

4.1.2

Sphinx extensions

N/A

Extra tools

N/A

Additional context

NOTE: If this was intentional, then users who do build under the source directory have their build files overwritten with each unit test, and then this is still a bug.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions