https://pantsbuild.org/ logo
#plugins
Title
# plugins
g

gorgeous-winter-99296

03/16/2023, 9:12 AM
I'm trying to use
run_pants
to add some tests for some of my plugins to start squashing bugs (thanks @bitter-ability-32190 for the push!). However; when I use it in my package repo I hit the following:
Copy code
pants.base.build_root.BuildRoot.NotFoundError: No build root detected. Pants detects the build root by looking for at least one file from ['pants', 'BUILDROOT', 'BUILD_ROOT'] in the cwd and its ancestors. If you have none of these files, you can create an empty file in your build root.
The full code is here; but what I've got is pretty much:
Copy code
def test_run_oci_container() -> None:
    build_inputs = {
        "BUILD_ROOT": "",
        "oci/BUILD": dedent(...),
        "oci/example.py": dedent(...),
    }

    with setup_tmpdir(build_inputs) as tmpdir:
        result = run_pants(
            [
                "--backend-packages=pants_backend_oci",
                "run",
                f"{tmpdir}/oci:oci",
            ]
        )

    assert result.stdout == "Hello world!\n"
    assert result.exit_code == 0
The BUILD_ROOT I've added to see if it's required but no dice. Currently testing on 2.14.
e

enough-analyst-54434

03/16/2023, 9:22 AM
Seems crappy and maybe outdated, but you need to actually check that file in apparently.
g

gorgeous-winter-99296

03/16/2023, 9:40 AM
No dice; adding those locally has no impact. 😞 It looks like it's failing inside the test itself? Hm.
Same on 2.15.0 too.
e

enough-analyst-54434

03/16/2023, 10:12 AM
Check out the dependencies of pants_integration_test in the Pants repo: https://github.com/pantsbuild/pants/blob/main/src/python/pants/testutil/BUILD That suggests an attack.
g

gorgeous-winter-99296

03/16/2023, 10:30 AM
Awesome, got closer now at least. Now it's not finding the backends 🙇 I had to explicitly depend on the
//BUILD_ROOT:files
target in my python_test.
3 Views