test\integration\test_build.py
-- -- --- --- --- --- --- --- ------- ------- ------- | """
-- -- --- --- --- --- --- --- ------- ------- ------- | Tests for the wily build command.
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | All of the following tests will use a click CLI runner to fully simulate the CLI.
-- -- --- --- --- --- --- --- ------- ------- ------- | Many of the tests will depend on a "builddir" fixture which is a compiled wily cache.
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | TODO : Test build + build with extra operator
-- -- --- --- --- --- --- --- ------- ------- ------- | """
-- -- --- --- --- --- --- --- ------- ------- ------- | import pathlib
-- -- --- --- --- --- --- --- ------- ------- ------- | import sys
-- -- --- --- --- --- --- --- ------- ------- ------- | from unittest.mock import patch
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | import pytest
-- -- --- --- --- --- --- --- ------- ------- ------- | from click.testing import CliRunner
-- -- --- --- --- --- --- --- ------- ------- ------- | from git.repo.base import Repo
-- -- --- --- --- --- --- --- ------- ------- ------- | from git.util import Actor
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | import wily.__main__ as main
-- -- --- --- --- --- --- --- ------- ------- ------- | from wily.archivers import ALL_ARCHIVERS
-- -- --- --- --- --- --- --- ------- ------- ------- | from wily.helper import generate_cache_path
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | _path = "src\\test.py" if sys.platform == "win32" else "src/test.py"
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | def test_build_not_git_repo(tmpdir, cache_path):
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | """
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | Test that build defaults to filesystem in a non-git directory
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | """
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | runner = CliRunner()
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | result = runner.invoke(
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | main.cli, ["--path", tmpdir, "--cache", cache_path, "build", "test.py"]
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | )
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | assert result.exit_code == 0, result.stdout
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | cache_path = pathlib.Path(cache_path)
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | assert cache_path.exists()
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | index_path = cache_path / "filesystem" / "index.json"
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | assert index_path.exists()
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 01 003 009 006 011 012 017 0060.94 0111.73 0001.83 | def test_build_custom_cache(tmpdir):
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | """
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | Test that build defaults to filesystem in a non-git directory with custom cache path.
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | """
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | runner = CliRunner()
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | result = runner.invoke(
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | main.cli, ["--path", tmpdir, "--cache", tmpdir / ".wily", "build", "test.py"]
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | )
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | assert result.exit_code == 0, result.stdout
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | cache_path = tmpdir / ".wily"
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | assert cache_path.exists()
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | index_path = cache_path / "filesystem" / "index.json"
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | assert index_path.exists()
-- -- 003 009 006 011 012 017 0060.94 0111.73 0001.83 | assert not pathlib.Path(generate_cache_path(tmpdir)).exists()
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 01 001 002 001 002 003 003 0004.75 0002.38 0000.50 | def test_build_invalid_path():
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | """
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | Test that build fails with a garbage path
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | """
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | runner = CliRunner()
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | result = runner.invoke(main.cli, ["--path", "/fo/v/a", "build", "test.py"])
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | assert result.exit_code == 1, result.stdout
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | def test_build_crash(tmpdir):
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | """
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | Simulate a runtime error in the build.
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | """
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | repo = Repo.init(path=tmpdir)
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | tmppath = pathlib.Path(tmpdir)
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 |
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | # Write a test file to the repo
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | with open(tmppath / "test.py", "w") as test_txt:
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | test_txt.write("import abc")
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 |
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | index = repo.index
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | index.add(["test.py"])
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 |
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | author = Actor("An author", "author@example.com")
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | committer = Actor("A committer", "committer@example.com")
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 |
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | index.commit("basic test", author=author, committer=committer)
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | repo.close()
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 |
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | import wily.commands.build
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 |
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | with patch.object(
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | wily.commands.build.Bar, "finish", side_effect=RuntimeError("arggh")
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | ) as bar_finish:
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | runner = CliRunner()
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | result = runner.invoke(main.cli, ["--path", tmpdir, "build", "test.py"])
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 | assert bar_finish.called_once
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 | assert result.exit_code == 1, result.stdout
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 01 003 012 007 014 015 021 0082.04 0143.58 0001.75 | def test_build(tmpdir, cache_path):
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | """
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | Test that build works in a basic repository.
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | """
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | repo = Repo.init(path=tmpdir)
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | tmppath = pathlib.Path(tmpdir)
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 |
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | # Write a test file to the repo
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | with open(tmppath / "test.py", "w") as test_txt:
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | test_txt.write("import abc")
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 |
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | index = repo.index
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | index.add(["test.py"])
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 |
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | author = Actor("An author", "author@example.com")
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | committer = Actor("A committer", "committer@example.com")
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 |
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | commit = index.commit("basic test", author=author, committer=committer)
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | repo.close()
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 |
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | runner = CliRunner()
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | result = runner.invoke(
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | main.cli,
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | ["--debug", "--path", tmpdir, "--cache", cache_path, "build", "test.py"],
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | )
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | assert result.exit_code == 0, result.stdout
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 |
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | cache_path = pathlib.Path(cache_path)
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | assert cache_path.exists()
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | index_path = cache_path / "git" / "index.json"
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | assert index_path.exists()
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | rev_path = cache_path / "git" / (commit.name_rev.split(" ")[0] + ".json")
-- -- 003 012 007 014 015 021 0082.04 0143.58 0001.75 | assert rev_path.exists()
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | @pytest.mark.skipif(sys.platform == "win32", reason="does not run on windows")
-- 01 003 013 008 016 016 024 0096.00 0177.23 0001.85 | def test_build_with_config(tmpdir, cache_path):
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | """
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | Test that build works in a basic repository and a configuration file.
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | """
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | repo = Repo.init(path=tmpdir)
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | tmppath = pathlib.Path(tmpdir)
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 |
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | config = """
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | [wily]
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | path = test.py
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | operators = raw, maintainability
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | """
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | config_path = tmppath / "wily.cfg"
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | with open(config_path, "w") as config_f:
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | config_f.write(config)
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 |
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | # Write a test file to the repo
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | with open(tmppath / "test.py", "w") as test_txt:
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | test_txt.write("import abc")
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 |
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | index = repo.index
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | index.add(["test.py"])
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 |
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | author = Actor("An author", "author@example.com")
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | committer = Actor("A committer", "committer@example.com")
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 |
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | commit = index.commit("basic test", author=author, committer=committer)
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | repo.close()
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 |
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | runner = CliRunner()
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | result = runner.invoke(
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | main.cli,
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | [
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | "--debug",
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | "--config",
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | config_path,
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | "--path",
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | tmpdir,
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | "--cache",
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | cache_path,
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | "build",
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | ],
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | )
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | assert result.exit_code == 0, result.stdout
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 |
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | cache_path = pathlib.Path(cache_path)
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | assert cache_path.exists()
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | index_path = cache_path / "git" / "index.json"
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | assert index_path.exists()
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | rev_path = cache_path / "git" / (commit.name_rev.split(" ")[0] + ".json")
-- -- 003 013 008 016 016 024 0096.00 0177.23 0001.85 | assert rev_path.exists()
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 01 003 015 013 026 018 039 0162.63 0422.83 0002.60 | def test_build_twice(tmpdir, cache_path):
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | """
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | Test that build works when run twice.
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | """
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | repo = Repo.init(path=tmpdir)
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | tmppath = pathlib.Path(tmpdir)
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 |
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | # Write a test file to the repo
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | with open(tmppath / "test.py", "w") as test_txt:
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | test_txt.write("import abc")
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 |
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | index = repo.index
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | index.add(["test.py"])
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 |
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | author = Actor("An author", "author@example.com")
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | committer = Actor("A committer", "committer@example.com")
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 |
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | commit = index.commit("basic test", author=author, committer=committer)
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 |
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | runner = CliRunner()
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | result = runner.invoke(
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | main.cli,
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | ["--debug", "--path", tmpdir, "--cache", cache_path, "build", "test.py"],
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | )
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | assert result.exit_code == 0, result.stdout
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 |
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | cache_path = pathlib.Path(cache_path) / "git"
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | assert cache_path.exists()
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | index_path = cache_path / "index.json"
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | assert index_path.exists()
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | rev_path = cache_path / (commit.name_rev.split(" ")[0] + ".json")
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | assert rev_path.exists()
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 |
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | # Write a test file to the repo
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | with open(tmppath / "test.py", "w") as test_txt:
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | test_txt.write("import abc\nfoo = 1")
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 |
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | index.add(["test.py"])
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 |
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | commit2 = index.commit("basic test", author=author, committer=committer)
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | repo.close()
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 |
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | result = runner.invoke(main.cli, ["--debug", "--path", tmpdir, "build", "test.py"])
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | assert result.exit_code == 0, result.stdout
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 |
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | assert cache_path.exists()
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | index_path = cache_path / "index.json"
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | assert index_path.exists()
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | rev_path = cache_path / (commit.name_rev.split(" ")[0] + ".json")
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | assert rev_path.exists()
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | rev_path2 = cache_path / (commit2.name_rev.split(" ")[0] + ".json")
-- -- 003 015 013 026 018 039 0162.63 0422.83 0002.60 | assert rev_path2.exists()
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 01 001 002 001 002 003 003 0004.75 0002.38 0000.50 | def test_build_no_commits(tmpdir):
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | """
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | Test that build fails cleanly with no commits
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | """
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | repo = Repo.init(path=tmpdir)
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | repo.close()
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | runner = CliRunner()
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | result = runner.invoke(
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | main.cli, ["--debug", "--path", tmpdir, "build", tmpdir, "--skip-ignore-check"]
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | )
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | assert result.exit_code == 1, result.stdout
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 01 002 004 002 004 006 006 0015.51 0015.51 0001.00 | def test_build_dirty_repo(builddir):
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 | """
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 | Test that build fails cleanly with a dirty repo
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 | """
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 | tmppath = pathlib.Path(builddir)
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 | with open(tmppath / "test.py", "w") as test_txt:
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 | test_txt.write("import abc\nfoo = 1")
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 |
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 | runner = CliRunner()
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 | result = runner.invoke(main.cli, ["--debug", "--path", builddir, "build", builddir])
-- -- 002 004 002 004 006 006 0015.51 0015.51 0001.00 | assert result.exit_code == 1, result.stdout
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- 01 001 002 001 002 003 003 0004.75 0002.38 0000.50 | def test_build_no_git_history(tmpdir):
-- 01 001 002 001 002 003 003 0004.75 0002.38 0000.50 | repo = Repo.init(path=tmpdir)
-- 01 001 002 001 002 003 003 0004.75 0002.38 0000.50 | repo.close()
-- 01 001 002 001 002 003 003 0004.75 0002.38 0000.50 |
-- 01 001 002 001 002 003 003 0004.75 0002.38 0000.50 | with patch("wily.logger") as logger:
-- 01 001 002 001 002 003 003 0004.75 0002.38 0000.50 | runner = CliRunner()
-- 01 001 002 001 002 003 003 0004.75 0002.38 0000.50 | result = runner.invoke(main.cli, ["--path", tmpdir, "build", _path])
-- -- 001 002 001 002 003 003 0004.75 0002.38 0000.50 | assert result.exit_code == 1, result.stdout
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | archivers = set(ALL_ARCHIVERS)
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- |
-- -- --- --- --- --- --- --- ------- ------- ------- | @pytest.mark.parametrize("archiver", archivers)
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | def test_build_archiver(gitdir, archiver, cache_path):
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | """
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | Test the build against each type of archiver
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | """
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | with patch("wily.logger") as logger:
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | runner = CliRunner()
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | result = runner.invoke(
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | main.cli,
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | ["--path", gitdir, "--cache", cache_path, "build", _path, "-a", archiver],
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | )
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | assert result.exit_code == 0, result.stdout
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | cache_path = pathlib.Path(cache_path)
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | assert cache_path.exists()
-- 01 002 006 003 006 008 009 0027.00 0027.00 0001.00 | index_path = cache_path / archiver / "index.json"
-- -- 002 006 003 006 008 009 0027.00 0027.00 0001.00 | assert index_path.exists()