def test_builder_without_jujuignore(tmp_path): """Without a .jujuignore we still have a default set of ignores""" metadata = tmp_path / CHARM_METADATA metadata.write_text("name: crazycharm") build_dir = tmp_path / BUILD_DIRNAME build_dir.mkdir() builder = CharmBuilder( charmdir=tmp_path, builddir=build_dir, entrypoint=pathlib.Path("whatever"), ) ignore = builder._load_juju_ignore() assert ignore.match("/.git", is_dir=True) assert ignore.match("/build", is_dir=True) assert not ignore.match("myfile.py", is_dir=False)
def test_builder_with_jujuignore(tmp_path): """With a .jujuignore we will include additional ignores.""" metadata = tmp_path / CHARM_METADATA metadata.write_text("name: crazycharm") build_dir = tmp_path / BUILD_DIRNAME build_dir.mkdir() with (tmp_path / ".jujuignore").open("w", encoding="utf-8") as ignores: ignores.write("*.py\n" "/h\xef.txt\n") builder = CharmBuilder( charmdir=tmp_path, builddir=build_dir, entrypoint=pathlib.Path("whatever"), ) ignore = builder._load_juju_ignore() assert ignore.match("/.git", is_dir=True) assert ignore.match("/build", is_dir=True) assert ignore.match("myfile.py", is_dir=False) assert not ignore.match("hi.txt", is_dir=False) assert ignore.match("h\xef.txt", is_dir=False) assert not ignore.match("myfile.c", is_dir=False)