Exemplo n.º 1
0
def test_run_script(is_library, tmpdir):
    build_dir = Path(tmpdir.mkdir("build"))
    src_dir = Path(tmpdir.mkdir("build/package_name"))
    script = "touch out.txt"
    build_metadata = {"script": script, "library": is_library}
    with buildpkg.BashRunnerWithSharedEnvironment() as shared_env:
        buildpkg.run_script(build_dir, src_dir, build_metadata, shared_env)
        assert (src_dir / "out.txt").exists()
Exemplo n.º 2
0
def test_run_script_environment(tmpdir):
    build_dir = Path(tmpdir.mkdir("build"))
    src_dir = Path(tmpdir.mkdir("build/package_name"))
    script = "export A=2"
    build_metadata = {"script": script, "library": False}
    with buildpkg.BashRunnerWithSharedEnvironment() as shared_env:
        shared_env.env.pop("A", None)
        buildpkg.run_script(build_dir, src_dir, build_metadata, shared_env)
        assert shared_env.env["A"] == "2"
Exemplo n.º 3
0
def test_subprocess_with_shared_env():
    with buildpkg.BashRunnerWithSharedEnvironment() as p:
        p.env.pop("A", None)

        res = p.run("A=6; echo $A", stdout=subprocess.PIPE)
        assert res.stdout == b"6\n"
        assert p.env.get("A", None) is None

        p.run("export A=2")
        assert p.env["A"] == "2"

        res = p.run("echo $A", stdout=subprocess.PIPE)
        assert res.stdout == b"2\n"

        res = p.run("A=6; echo $A", stdout=subprocess.PIPE)
        assert res.stdout == b"6\n"
        assert p.env.get("A", None) == "6"

        p.env["A"] = "7"
        res = p.run("echo $A", stdout=subprocess.PIPE)
        assert res.stdout == b"7\n"
        assert p.env["A"] == "7"