wide-midnight-78598
12/27/2023, 4:13 PMrun_pants would cause Exception message: Absolute spec path /tmpwknl1265/hellotest does not share build root /private/var/folders/dy/q08y_dts5vd71rm99t4gc9lr0000gp/T/pants-sandbox-PRzKuW on a new test?
I feel like I've messed up my environment somehow - am I missing.... something?wide-midnight-78598
12/27/2023, 4:13 PMsources = {
"hellotest/main.py": dedent(
"""\
import colors
import sys
from hellotest.utils.greeter import GREET
print(GREET)
sys.exit(42)
"""
),
"hellotest/BUILD": dedent(
"""\
python_requirement(name="req", requirements=["ansicolors==1.1.8"])
python_sources(name="lib")
python_distribution(
name="dist",
dependencies=[":lib"],
provides=python_artifact(name="main-dist", version="0.0.1"),
)
"""
),
}
with setup_tmpdir(sources) as tmpdir:
package_args = [
"--backend-packages=['pants.backend.python']",
"--python-interpreter-constraints=['>=3.8,<4']",
f"--source-root-patterns=['/{tmpdir}']",
"package",
f"/{tmpdir}/hellotest:bin",
]
package_result = run_pants(package_args)
package_result.assert_success()wide-midnight-78598
12/27/2023, 4:15 PMrun_pants already runs stuff in it's own subdir?wide-midnight-78598
12/27/2023, 4:18 PMsetup_tmpdir and run_pants use different temp dirs?wide-midnight-78598
12/27/2023, 4:39 PMrun_pants in a folder where there is this fixture defined, even if I'm not using said fixture - my temp directory gets blown up?
@witty-crayon-22786 @happy-kitchen-89482 Ever run into this?
@pytest.fixture
def rule_runner() -> RuleRunner:
return RuleRunner(
rules=[
*peek.rules(),
*visibility_rules(),
QueryRule(TargetDatas, [RawSpecs]),
],
target_types=[FilesGeneratorTarget, GenericTarget, PythonSourceTarget,],
)
def test_non_matching_build_target(rule_runner: RuleRunner) -> None:
rule_runner.write_files({"some_name/BUILD": "target()"})
result = rule_runner.run_goal_rule(Peek, args=["other_name"])
assert result.stdout == "[]\n"
# Fails if the above code exists
def test_something() -> None:
sources = {
"src/test_file.txt": dedent(
"""\
I am a duck.
"""
),
"src/BUILD": dedent(
"""\
files(name="files", sources=["*.txt",])
system_binary(
name="cat",
binary_name="cat",
)
adhoc_tool(
name="adhoc",
runnable=":cat",
execution_dependencies=[":files",],
args=["test_file.txt",],
log_output=True,
stdout="stdout",
)
"""
),
}
with setup_tmpdir(sources) as tmpdir:
args = [
"--backend-packages=['pants.backend.experimental.adhoc',]",
f"--source-root-patterns=['{tmpdir}/src']",
"export-codegen",
f"{tmpdir}/src:adhoc",
]
result = run_pants(args)
assert "[INFO] I am a duck." in result.stderr.strip()wide-midnight-78598
12/27/2023, 4:40 PM