Repository: conda/conda-build

Issue:
Remove manual step of cloning conda_build_test_recipe
### Checklist

- [X] I added a descriptive title
- [X] I searched open requests and couldn't find a duplicate

### What is the idea?

Eliminate the manual clone of https://github.com/conda/conda_build_test_recipe.

### Why is this needed?

Requiring a manual clone has a few drawbacks:
- testing is harder, more things to remember to do
- makes CI more complex as we need to clone more things

### What should happen?

Converting the manual step into an automated fixture.

### Additional Context

_No response_


Discussion:

Resolving patch:
diff --git a/conda_build/api.py b/conda_build/api.py
--- a/conda_build/api.py
+++ b/conda_build/api.py
@@ -11,7 +11,8 @@
 
 # imports are done locally to keep the api clean and limited strictly
 #    to conda-build's functionality.
-
+from os.path import dirname, expanduser, join
+from pathlib import Path
 import sys as _sys
 
 # make the Config class available in the api namespace
@@ -20,7 +21,6 @@
 from conda_build.utils import ensure_list as _ensure_list
 from conda_build.utils import expand_globs as _expand_globs
 from conda_build.utils import get_logger as _get_logger
-from os.path import dirname, expanduser, join
 
 
 def render(recipe_path, config=None, variants=None, permit_unsatisfiable_variants=True,
@@ -100,7 +100,7 @@ def get_output_file_paths(recipe_path_or_metadata, no_download_source=False, con
             metadata = recipe_path_or_metadata
         else:
             raise ValueError(f"received mixed list of metas: {recipe_path_or_metadata}")
-    elif isinstance(recipe_path_or_metadata, str):
+    elif isinstance(recipe_path_or_metadata, (str, Path)):
         # first, render the parent recipe (potentially multiple outputs, depending on variants).
         metadata = render(recipe_path_or_metadata, no_download_source=no_download_source,
                             variants=variants, config=config, finalize=True, **kwargs)


Test patch:
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -88,13 +88,6 @@ jobs:
           path: ./src
           fetch-depth: 0
 
-      - name: Checkout test recipe
-        uses: actions/checkout@v3
-        with:
-          repository: conda/conda_build_test_recipe
-          path: ./conda_build_test_recipe
-          fetch-depth: 0
-
       - name: Timestamp
         run: echo "TIMESTAMP=$(date -u "+%Y%m")" >> $GITHUB_ENV
         shell: bash
@@ -199,13 +192,6 @@ jobs:
           path: .\src
           fetch-depth: 0
 
-      - name: Checkout test recipe
-        uses: actions/checkout@v3
-        with:
-          repository: conda/conda_build_test_recipe
-          path: .\conda_build_test_recipe
-          fetch-depth: 0
-
       - name: Timestamp
         run: echo "TIMESTAMP=$(date -u "+%Y%m")" >> $GITHUB_ENV
         shell: bash
@@ -315,13 +301,6 @@ jobs:
           path: ./src
           fetch-depth: 0
 
-      - name: Checkout test recipe
-        uses: actions/checkout@v3
-        with:
-          repository: conda/conda_build_test_recipe
-          path: ./conda_build_test_recipe
-          fetch-depth: 0
-
       - name: Timestamp
         run: echo "TIMESTAMP=$(date -u "+%Y%m")" >> $GITHUB_ENV
         shell: bash
diff --git a/tests/cli/test_main_build.py b/tests/cli/test_main_build.py
--- a/tests/cli/test_main_build.py
+++ b/tests/cli/test_main_build.py
@@ -27,7 +27,7 @@ def _reset_config(search_path=None):
 
 
 @pytest.mark.sanity
-def test_build():
+def test_build_empty_sections(conda_build_test_recipe_envvar: str):
     args = [
         "--no-anaconda-upload",
         os.path.join(metadata_dir, "empty_sections"),
@@ -294,7 +294,12 @@ def test_conda_py_no_period(testing_workdir, testing_metadata, monkeypatch):
     assert any("py36" in output for output in outputs)
 
 
-def test_build_skip_existing(testing_workdir, capfd, mocker):
+def test_build_skip_existing(
+    testing_workdir,
+    capfd,
+    mocker,
+    conda_build_test_recipe_envvar: str,
+):
     # build the recipe first
     empty_sections = os.path.join(metadata_dir, "empty_sections")
     args = ["--no-anaconda-upload", empty_sections]
@@ -309,7 +314,11 @@ def test_build_skip_existing(testing_workdir, capfd, mocker):
     assert "are already built" in output or "are already built" in error
 
 
-def test_build_skip_existing_croot(testing_workdir, capfd):
+def test_build_skip_existing_croot(
+    testing_workdir,
+    capfd,
+    conda_build_test_recipe_envvar: str,
+):
     # build the recipe first
     empty_sections = os.path.join(metadata_dir, "empty_sections")
     args = ["--no-anaconda-upload", "--croot", testing_workdir, empty_sections]
@@ -351,7 +360,7 @@ def test_activate_scripts_not_included(testing_workdir):
         assert not package_has_file(out, f)
 
 
-def test_relative_path_croot():
+def test_relative_path_croot(conda_build_test_recipe_envvar: str):
     # this tries to build a package while specifying the croot with a relative path:
     # conda-build --no-test --croot ./relative/path
 
@@ -364,7 +373,7 @@ def test_relative_path_croot():
     assert os.path.isfile(outputfile[0])
 
 
-def test_relative_path_test_artifact():
+def test_relative_path_test_artifact(conda_build_test_recipe_envvar: str):
     # this test builds a package into (cwd)/relative/path and then calls:
     # conda-build --test ./relative/path/{platform}/{artifact}.tar.bz2
 
@@ -386,7 +395,7 @@ def test_relative_path_test_artifact():
     main_build.execute(args)
 
 
-def test_relative_path_test_recipe():
+def test_relative_path_test_recipe(conda_build_test_recipe_envvar: str):
     # this test builds a package into (cwd)/relative/path and then calls:
     # conda-build --test --croot ./relative/path/ /abs/path/to/recipe
 
diff --git a/tests/conftest.py b/tests/conftest.py
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,6 +1,7 @@
 # Copyright (C) 2014 Anaconda, Inc
 # SPDX-License-Identifier: BSD-3-Clause
 from collections import defaultdict
+from pathlib import Path
 import os
 import subprocess
 import sys
@@ -225,3 +226,29 @@ def variants_conda_build_sysroot(monkeypatch, request):
         ).stdout.strip(),
     )
     return request.param
+
+
+@pytest.fixture(scope="session")
+def conda_build_test_recipe_path(tmp_path_factory: pytest.TempPathFactory) -> Path:
+    """Clone conda_build_test_recipe.
+
+    This exposes the special dummy package "source code" used to test various git/svn/local recipe configurations.
+    """
+    # clone conda_build_test_recipe locally
+    repo = tmp_path_factory.mktemp("conda_build_test_recipe", numbered=False)
+    subprocess.run(
+        ["git", "clone", "https://github.com/conda/conda_build_test_recipe", str(repo)],
+        check=True,
+    )
+    return repo
+
+
+@pytest.fixture
+def conda_build_test_recipe_envvar(
+    conda_build_test_recipe_path: Path,
+    monkeypatch: pytest.MonkeyPatch,
+) -> str:
+    """Exposes the cloned conda_build_test_recipe as an environment variable."""
+    name = "CONDA_BUILD_TEST_RECIPE_PATH"
+    monkeypatch.setenv(name, conda_build_test_recipe_path)
+    return name
diff --git a/tests/test-recipes/fail/source_git_jinja2_oops/meta.yaml b/tests/test-recipes/fail/source_git_jinja2_oops/meta.yaml
--- a/tests/test-recipes/fail/source_git_jinja2_oops/meta.yaml
+++ b/tests/test-recipes/fail/source_git_jinja2_oops/meta.yaml
@@ -3,7 +3,7 @@ package:
   version: {{ GIT_DSECRIBE_TAG }}
 
 source:
-  git_url: ../../../../../conda_build_test_recipe
+  git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
   git_tag: 1.20.2
 
 requirements:
diff --git a/tests/test-recipes/metadata/_osx_is_app_missing_python_app/meta.yaml b/tests/test-recipes/metadata/_osx_is_app_missing_python_app/meta.yaml
--- a/tests/test-recipes/metadata/_osx_is_app_missing_python_app/meta.yaml
+++ b/tests/test-recipes/metadata/_osx_is_app_missing_python_app/meta.yaml
@@ -3,7 +3,7 @@ package:
   version: 1.0
 
 source:
-  path: ../../../../../conda_build_test_recipe
+  path: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
 
 build:
   entry_points:
diff --git a/tests/test-recipes/metadata/_source_git_jinja2_relative_git_url/meta.yaml b/tests/test-recipes/metadata/_source_git_jinja2_relative_git_url/meta.yaml
--- a/tests/test-recipes/metadata/_source_git_jinja2_relative_git_url/meta.yaml
+++ b/tests/test-recipes/metadata/_source_git_jinja2_relative_git_url/meta.yaml
@@ -7,4 +7,4 @@ build:
   string: {{ environ.get('GIT_DESCRIBE_NUMBER', '0') + '_JPMC' }}
 
 source:
-  git_url: ../../../../../conda_build_test_recipe
+  git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
diff --git a/tests/test-recipes/metadata/_source_git_jinja2_relative_path/meta.yaml b/tests/test-recipes/metadata/_source_git_jinja2_relative_path/meta.yaml
--- a/tests/test-recipes/metadata/_source_git_jinja2_relative_path/meta.yaml
+++ b/tests/test-recipes/metadata/_source_git_jinja2_relative_path/meta.yaml
@@ -7,4 +7,4 @@ build:
   string: {{ environ.get('GIT_DESCRIBE_NUMBER', '0') + '_JPMC' }}
 
 source:
-  path: ../../../../../conda_build_test_recipe
+  path: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
diff --git a/tests/test-recipes/metadata/_source_setuptools/meta.yaml b/tests/test-recipes/metadata/_source_setuptools/meta.yaml
--- a/tests/test-recipes/metadata/_source_setuptools/meta.yaml
+++ b/tests/test-recipes/metadata/_source_setuptools/meta.yaml
@@ -13,7 +13,7 @@ package:
   version: {{ data.get('version') }}
 
 source:
-  git_url: ../../../../../conda_build_test_recipe
+  git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
   git_tag: 1.21.0
 
 requirements:
diff --git a/tests/test-recipes/metadata/empty_sections/meta.yaml b/tests/test-recipes/metadata/empty_sections/meta.yaml
--- a/tests/test-recipes/metadata/empty_sections/meta.yaml
+++ b/tests/test-recipes/metadata/empty_sections/meta.yaml
@@ -3,7 +3,7 @@ package:
   version: 0.0
 
 source:
-  path: ../../../../../conda_build_test_recipe
+  path: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
 
 build:
 
diff --git a/tests/test-recipes/metadata/empty_with_build_script/meta.yaml b/tests/test-recipes/metadata/empty_with_build_script/meta.yaml
--- a/tests/test-recipes/metadata/empty_with_build_script/meta.yaml
+++ b/tests/test-recipes/metadata/empty_with_build_script/meta.yaml
@@ -3,7 +3,7 @@ package:
   version: 0.0
 
 source:
-  path: ../../../../../conda_build_test_recipe
+  path: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
 
 build:
 
diff --git a/tests/test-recipes/metadata/jinja2_build_str/meta.yaml b/tests/test-recipes/metadata/jinja2_build_str/meta.yaml
--- a/tests/test-recipes/metadata/jinja2_build_str/meta.yaml
+++ b/tests/test-recipes/metadata/jinja2_build_str/meta.yaml
@@ -3,7 +3,7 @@ package:
   version: 1.0
 
 source:
-  path: ../../../../../conda_build_test_recipe
+  path: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
 
 build:
   string: {{ PKG_BUILDNUM }}_g{{ GIT_FULL_HASH[:7] }}
diff --git a/tests/test-recipes/metadata/osx_is_app/meta.yaml b/tests/test-recipes/metadata/osx_is_app/meta.yaml
--- a/tests/test-recipes/metadata/osx_is_app/meta.yaml
+++ b/tests/test-recipes/metadata/osx_is_app/meta.yaml
@@ -3,7 +3,7 @@ package:
   version: 1.0
 
 source:
-  path: ../../../../../conda_build_test_recipe
+  path: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
 
 build:
   entry_points:
diff --git a/tests/test-recipes/metadata/source_multiple/meta.yaml b/tests/test-recipes/metadata/source_multiple/meta.yaml
--- a/tests/test-recipes/metadata/source_multiple/meta.yaml
+++ b/tests/test-recipes/metadata/source_multiple/meta.yaml
@@ -3,7 +3,7 @@ package:
   version: 1.0
 
 source:
-  - path: ../../../../../conda_build_test_recipe
+  - path: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
 
   - git_url: https://github.com/conda/conda_build_test_recipe
     git_tag: 1.20.2
diff --git a/tests/test-recipes/metadata/source_path/meta.yaml b/tests/test-recipes/metadata/source_path/meta.yaml
--- a/tests/test-recipes/metadata/source_path/meta.yaml
+++ b/tests/test-recipes/metadata/source_path/meta.yaml
@@ -3,4 +3,4 @@ package:
   version: 1.0
 
 source:
-  path: ../../../../../conda_build_test_recipe
+  path: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
diff --git a/tests/test-recipes/metadata/source_regex/meta.yaml b/tests/test-recipes/metadata/source_regex/meta.yaml
--- a/tests/test-recipes/metadata/source_regex/meta.yaml
+++ b/tests/test-recipes/metadata/source_regex/meta.yaml
@@ -10,7 +10,7 @@ package:
   version: {{ data.group(1) }}
 
 source:
-  git_url: ../../../../../conda_build_test_recipe
+  git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
   git_tag: 1.21.0
 
 build:
diff --git a/tests/test-recipes/metadata/source_regex_from_recipe_dir/meta.yaml b/tests/test-recipes/metadata/source_regex_from_recipe_dir/meta.yaml
--- a/tests/test-recipes/metadata/source_regex_from_recipe_dir/meta.yaml
+++ b/tests/test-recipes/metadata/source_regex_from_recipe_dir/meta.yaml
@@ -10,7 +10,7 @@ package:
   version: {{ data.group(1) }}
 
 source:
-  git_url: ../../../../../conda_build_test_recipe
+  git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
   git_tag: 1.21.0
 
 build:
diff --git a/tests/test-recipes/metadata/source_setup_py_data/meta.yaml b/tests/test-recipes/metadata/source_setup_py_data/meta.yaml
--- a/tests/test-recipes/metadata/source_setup_py_data/meta.yaml
+++ b/tests/test-recipes/metadata/source_setup_py_data/meta.yaml
@@ -11,7 +11,7 @@ package:
   version: {{ data.get('version') }}
 
 source:
-  git_url: ../../../../../conda_build_test_recipe
+  git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
   git_tag: 1.21.0
 
 build:
diff --git a/tests/test-recipes/metadata/source_setup_py_data_subdir/meta.yaml b/tests/test-recipes/metadata/source_setup_py_data_subdir/meta.yaml
--- a/tests/test-recipes/metadata/source_setup_py_data_subdir/meta.yaml
+++ b/tests/test-recipes/metadata/source_setup_py_data_subdir/meta.yaml
@@ -11,7 +11,7 @@ package:
   version: {{ data.get('version') }}
 
 source:
-  git_url: ../../../../../conda_build_test_recipe
+  git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
   git_tag: 1.21.0
   folder: src
 
diff --git a/tests/test-recipes/published_code/building_jinja2_direct_env_vars/meta.yaml b/tests/test-recipes/published_code/building_jinja2_direct_env_vars/meta.yaml
--- a/tests/test-recipes/published_code/building_jinja2_direct_env_vars/meta.yaml
+++ b/tests/test-recipes/published_code/building_jinja2_direct_env_vars/meta.yaml
@@ -10,4 +10,4 @@ build:
   string: {{ GIT_BUILD_STR }}
 
 source:
-  git_url: ../../../../../conda_build_test_recipe
+  git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
diff --git a/tests/test-recipes/published_code/building_jinja2_environ/meta.yaml b/tests/test-recipes/published_code/building_jinja2_environ/meta.yaml
--- a/tests/test-recipes/published_code/building_jinja2_environ/meta.yaml
+++ b/tests/test-recipes/published_code/building_jinja2_environ/meta.yaml
@@ -10,4 +10,4 @@ build:
   string: {{ environ.get('GIT_BUILD_STR', '') }}
 
 source:
-  git_url: ../../../../../conda_build_test_recipe
+  git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
diff --git a/tests/test-recipes/published_code/building_jinja2_setup_py_data/meta.yaml b/tests/test-recipes/published_code/building_jinja2_setup_py_data/meta.yaml
--- a/tests/test-recipes/published_code/building_jinja2_setup_py_data/meta.yaml
+++ b/tests/test-recipes/published_code/building_jinja2_setup_py_data/meta.yaml
@@ -7,7 +7,7 @@ package:
 # source will be downloaded prior to filling in jinja templates
 # Example assumes that this folder has setup.py in it
 source:
-  git_url: ../../../../../conda_build_test_recipe
+  git_url: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
   git_tag: 1.21.0
 
 requirements:
diff --git a/tests/test-recipes/split-packages/_alternate_type_wheel/meta.yaml b/tests/test-recipes/split-packages/_alternate_type_wheel/meta.yaml
--- a/tests/test-recipes/split-packages/_alternate_type_wheel/meta.yaml
+++ b/tests/test-recipes/split-packages/_alternate_type_wheel/meta.yaml
@@ -3,7 +3,7 @@ package:
   version: 1.0
 
 source:
-  path: ../../../../../conda_build_test_recipe
+  path: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
 
 outputs:
   - type: wheel
diff --git a/tests/test-recipes/split-packages/_git_in_output_version/meta.yaml b/tests/test-recipes/split-packages/_git_in_output_version/meta.yaml
--- a/tests/test-recipes/split-packages/_git_in_output_version/meta.yaml
+++ b/tests/test-recipes/split-packages/_git_in_output_version/meta.yaml
@@ -3,7 +3,7 @@ package:
   version: 1.0
 
 source:
-  path: ../../../../../conda_build_test_recipe
+  path: {{ environ.get('CONDA_BUILD_TEST_RECIPE_PATH') }}
 
 requirements:
   build:
diff --git a/tests/test_api_build.py b/tests/test_api_build.py
--- a/tests/test_api_build.py
+++ b/tests/test_api_build.py
@@ -38,10 +38,13 @@
 from conda_build.conda_interface import reset_context
 from conda.exceptions import ClobberError, CondaMultiError
 
-from .utils import get_valid_recipes, metadata_dir, fail_dir, add_mangling
-
-# define a few commonly used recipes - use os.path.join(metadata_dir, recipe) elsewhere
-empty_sections = os.path.join(metadata_dir, "empty_sections")
+from .utils import (
+    get_valid_recipes,
+    metadata_dir,
+    fail_dir,
+    add_mangling,
+    metadata_path,
+)
 
 
 def represent_ordereddict(dumper, data):
@@ -88,7 +91,12 @@ def describe_root(cwd=None):
         for recipe in get_valid_recipes(metadata_dir)
     ],
 )
-def test_recipe_builds(recipe: Path, testing_config, monkeypatch):
+def test_recipe_builds(
+    recipe: Path,
+    testing_config,
+    monkeypatch: pytest.MonkeyPatch,
+    conda_build_test_recipe_envvar: str,
+):
     # TODO: After we fix #3754 this mark can be removed. This specific test
     #   ``source_setup_py_data_subdir`` reproduces the problem.
     if recipe.name == "source_setup_py_data_subdir":
@@ -167,8 +175,13 @@ def test_token_upload(testing_metadata):
 @pytest.mark.sanity
 @pytest.mark.serial
 @pytest.mark.parametrize("service_name", ["binstar", "anaconda"])
-def test_no_anaconda_upload_condarc(service_name, testing_config, capfd):
-    api.build(empty_sections, config=testing_config, notest=True)
+def test_no_anaconda_upload_condarc(
+    service_name: str,
+    testing_config,
+    capfd,
+    conda_build_test_recipe_envvar: str,
+):
+    api.build(str(metadata_path / "empty_sections"), config=testing_config, notest=True)
     output, error = capfd.readouterr()
     assert "Automatic uploading is disabled" in output, error
 
@@ -176,9 +189,11 @@ def test_no_anaconda_upload_condarc(service_name, testing_config, capfd):
 @pytest.mark.sanity
 @pytest.mark.serial
 @pytest.mark.parametrize("service_name", ["binstar", "anaconda"])
-def test_offline(service_name, testing_config):
-    with env_var('CONDA_OFFLINE', 'True', reset_context):
-        api.build(empty_sections, config=testing_config)
+def test_offline(
+    service_name: str, testing_config, conda_build_test_recipe_envvar: str
+):
+    with env_var("CONDA_OFFLINE", "True", reset_context):
+        api.build(str(metadata_path / "empty_sections"), config=testing_config)
 
 
 def test_git_describe_info_on_branch(testing_config):
@@ -274,24 +289,29 @@ def test_binary_has_prefix_files_non_utf8(testing_config):
     api.build(os.path.join(metadata_dir, '_binary_has_utf_non_8'), config=testing_config)
 
 
-def test_relative_path_git_versioning(testing_config):
-    # conda_build_test_recipe is a manual step.  Clone it at the same level as
-    #    your conda-build source.
-    cwd = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..',
-                                       'conda_build_test_recipe'))
-    tag = describe_root(cwd)
-    output = api.get_output_file_path(os.path.join(metadata_dir,
-                                                   "_source_git_jinja2_relative_path"),
-                                      config=testing_config)[0]
+def test_relative_path_git_versioning(
+    testing_config,
+    conda_build_test_recipe_path: Path,
+    conda_build_test_recipe_envvar: str,
+):
+    tag = describe_root(conda_build_test_recipe_path)
+    output = api.get_output_file_paths(
+        metadata_path / "_source_git_jinja2_relative_path",
+        config=testing_config,
+    )[0]
     assert tag in output
 
 
-def test_relative_git_url_git_versioning(testing_config):
-    cwd = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..',
-                                       'conda_build_test_recipe'))
-    tag = describe_root(cwd)
-    recipe = os.path.join(metadata_dir, "_source_git_jinja2_relative_git_url")
-    output = api.get_output_file_path(recipe, config=testing_config)[0]
+def test_relative_git_url_git_versioning(
+    testing_config,
+    conda_build_test_recipe_path: Path,
+    conda_build_test_recipe_envvar: str,
+):
+    tag = describe_root(conda_build_test_recipe_path)
+    output = api.get_output_file_paths(
+        metadata_path / "_source_git_jinja2_relative_git_url",
+        config=testing_config,
+    )[0]
     assert tag in output
 
 
@@ -414,10 +434,12 @@ def test_jinja_typo(testing_config):
 
 
 @pytest.mark.sanity
-def test_skip_existing(testing_config, capfd):
+def test_skip_existing(testing_config, capfd, conda_build_test_recipe_envvar: str):
     # build the recipe first
-    api.build(empty_sections, config=testing_config)
-    api.build(empty_sections, config=testing_config, skip_existing=True)
+    api.build(str(metadata_path / "empty_sections"), config=testing_config)
+    api.build(
+        str(metadata_path / "empty_sections"), config=testing_config, skip_existing=True
+    )
     output, error = capfd.readouterr()
     assert "are already built" in output
 
@@ -954,7 +976,7 @@ def test_workdir_removal_warning(testing_config, caplog):
 
 @pytest.mark.sanity
 @pytest.mark.skipif(sys.platform != 'darwin', reason="relevant to mac only")
-def test_append_python_app_osx(testing_config):
+def test_append_python_app_osx(testing_config, conda_build_test_recipe_envvar: str):
     """Recipes that use osx_is_app need to have python.app in their runtime requirements.
 
     conda-build will add it if it's missing."""
diff --git a/tests/test_api_test.py b/tests/test_api_test.py
--- a/tests/test_api_test.py
+++ b/tests/test_api_test.py
@@ -3,7 +3,6 @@
 """
 This module tests the test API.  These are high-level integration tests.
 """
-
 import os
 
 import pytest
@@ -37,8 +36,12 @@ def test_package_test_without_recipe_in_package(testing_metadata):
     api.test(output, config=testing_metadata.config)
 
 
-def test_package_with_jinja2_does_not_redownload_source(testing_config, mocker):
-    recipe = os.path.join(metadata_dir, 'jinja2_build_str')
+def test_package_with_jinja2_does_not_redownload_source(
+    testing_config,
+    mocker,
+    conda_build_test_recipe_envvar: str,
+):
+    recipe = os.path.join(metadata_dir, "jinja2_build_str")
     metadata = api.render(recipe, config=testing_config, dirty=True)[0][0]
     outputs = api.build(metadata, notest=True, anaconda_upload=False)
     # this recipe uses jinja2, which should trigger source download, except that source download
diff --git a/tests/test_published_examples.py b/tests/test_published_examples.py
--- a/tests/test_published_examples.py
+++ b/tests/test_published_examples.py
@@ -1,6 +1,7 @@
 # Copyright (C) 2014 Anaconda, Inc
 # SPDX-License-Identifier: BSD-3-Clause
 import os
+from pathlib import Path
 import sys
 
 import pytest
@@ -28,7 +29,11 @@ def test_skeleton_pypi():
         for recipe in get_valid_recipes(published_path)
     ],
 )
-def test_recipe_builds(recipe, testing_config):
+def test_recipe_builds(
+    recipe: Path,
+    testing_config,
+    conda_build_test_recipe_envvar: str,
+):
     # These variables are defined solely for testing purposes,
     # so they can be checked within build scripts
     build(str(recipe), config=testing_config)
diff --git a/tests/test_subpackages.py b/tests/test_subpackages.py
--- a/tests/test_subpackages.py
+++ b/tests/test_subpackages.py
@@ -107,7 +107,7 @@ def test_intradependencies(testing_config):
                                                                                                        outputs2_set)
 
 
-def test_git_in_output_version(testing_config):
+def test_git_in_output_version(testing_config, conda_build_test_recipe_envvar: str):
     recipe = os.path.join(subpackage_dir, '_git_in_output_version')
     outputs = api.render(recipe, config=testing_config, finalize=False, bypass_env_check=True)
     assert len(outputs) == 1