1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
|
From: =?utf-8?q?S=C3=A9bastien_Delafond?= <sdelafond@gmail.com>
Date: Sun, 5 Aug 2018 14:00:26 +0200
Subject: Remove test_cibuild.py
---
test/release/test_cibuild.py | 240 -------------------------------------------
1 file changed, 240 deletions(-)
delete mode 100644 test/release/test_cibuild.py
diff --git a/test/release/test_cibuild.py b/test/release/test_cibuild.py
deleted file mode 100644
index c1ec0ae..0000000
--- a/test/release/test_cibuild.py
+++ /dev/null
@@ -1,240 +0,0 @@
-import io
-from pathlib import Path
-
-import pytest
-
-from release import cibuild
-
-root = Path(__file__).parent.parent.parent
-
-
-def test_buildenviron_live():
- be = cibuild.BuildEnviron.from_env()
- assert be.release_dir
-
-
-def test_buildenviron_common():
- be = cibuild.BuildEnviron(
- system="Linux",
- root_dir=root,
- branch="main",
- )
- assert be.release_dir == be.root_dir / "release"
- assert be.dist_dir == be.root_dir / "release" / "dist"
- assert be.build_dir == be.root_dir / "release" / "build"
- assert not be.has_docker_creds
-
- cs = io.StringIO()
- be.dump_info(cs)
- assert cs.getvalue()
-
- be = cibuild.BuildEnviron(
- system="Unknown",
- root_dir=root,
- )
- with pytest.raises(cibuild.BuildError):
- be.version
- with pytest.raises(cibuild.BuildError):
- be.platform_tag
-
-
-def test_buildenviron_pr(monkeypatch):
- # Simulates a PR. We build everything, but don't have access to secret
- # credential env variables.
- monkeypatch.setenv("GITHUB_REF", "refs/pull/42/merge")
- monkeypatch.setenv("CI_BUILD_WHEEL", "1")
- monkeypatch.setenv("GITHUB_EVENT_NAME", "pull_request")
-
- be = cibuild.BuildEnviron.from_env()
- assert be.branch == "pr-42"
- assert be.is_pull_request
- assert be.should_build_wheel
- assert not be.should_upload_pypi
-
-
-def test_buildenviron_commit():
- # Simulates an ordinary commit on the master branch.
- be = cibuild.BuildEnviron(
- system="Linux",
- root_dir=root,
- branch="main",
- is_pull_request=False,
- should_build_wheel=True,
- should_build_pyinstaller=True,
- should_build_docker=True,
- docker_username="foo",
- docker_password="bar",
- has_aws_creds=True,
- )
- assert be.docker_tag == "mitmproxy/mitmproxy:dev"
- assert be.should_upload_docker
- assert not be.should_upload_pypi
- assert be.should_upload_docker
- assert be.should_upload_aws
- assert not be.is_prod_release
- assert not be.is_maintenance_branch
-
-
-def test_buildenviron_releasetag():
- # Simulates a tagged release on a release branch.
- be = cibuild.BuildEnviron(
- system="Linux",
- root_dir=root,
- tag="v0.0.1",
- should_build_wheel=True,
- should_build_docker=True,
- should_build_pyinstaller=True,
- has_twine_creds=True,
- docker_username="foo",
- docker_password="bar",
- )
- assert be.tag == "v0.0.1"
- assert be.branch is None
- assert be.version == "0.0.1"
- assert be.upload_dir == "0.0.1"
- assert be.docker_tag == "mitmproxy/mitmproxy:0.0.1"
- assert be.should_upload_pypi
- assert be.should_upload_docker
- assert be.is_prod_release
- assert not be.is_maintenance_branch
-
-
-def test_buildenviron_namedtag():
- # Simulates a non-release tag on a branch.
- be = cibuild.BuildEnviron(
- system="Linux",
- root_dir=root,
- tag="anyname",
- should_build_wheel=True,
- should_build_docker=True,
- should_build_pyinstaller=True,
- has_twine_creds=True,
- docker_username="foo",
- docker_password="bar",
- )
- assert be.tag == "anyname"
- assert be.branch is None
- assert be.version == "anyname"
- assert be.upload_dir == "anyname"
- assert be.docker_tag == "mitmproxy/mitmproxy:anyname"
- assert not be.should_upload_pypi
- assert not be.should_upload_docker
- assert not be.is_prod_release
- assert not be.is_maintenance_branch
-
-
-def test_buildenviron_dev_branch():
- # Simulates a commit on a development branch on the main repo
- be = cibuild.BuildEnviron(
- system="Linux",
- root_dir=root,
- branch="mybranch",
- should_build_wheel=True,
- should_build_docker=True,
- should_build_pyinstaller=True,
- has_twine_creds=True,
- docker_username="foo",
- docker_password="bar",
- )
- assert be.tag is None
- assert be.branch == "mybranch"
- assert be.version == "mybranch"
- assert be.upload_dir == "branches/mybranch"
- assert not be.should_upload_pypi
- assert not be.should_upload_docker
- assert not be.is_maintenance_branch
-
-
-def test_buildenviron_maintenance_branch():
- # Simulates a commit on a release maintenance branch on the main repo
- be = cibuild.BuildEnviron(
- system="Linux",
- root_dir=root,
- branch="v0.x",
- should_build_wheel=True,
- should_build_docker=True,
- should_build_pyinstaller=True,
- has_twine_creds=True,
- docker_username="foo",
- docker_password="bar",
- )
- assert be.tag is None
- assert be.branch == "v0.x"
- assert be.version == "v0.x"
- assert be.upload_dir == "branches/v0.x"
- assert not be.should_upload_pypi
- assert not be.should_upload_docker
- assert be.is_maintenance_branch
-
-
-def test_buildenviron_osx(tmp_path):
- be = cibuild.BuildEnviron(
- system="Darwin",
- root_dir=root,
- tag="v0.0.1",
- )
- assert be.platform_tag == "osx"
- assert be.archive_path == be.dist_dir / "mitmproxy-0.0.1-osx.tar.gz"
-
- with be.archive(tmp_path / "arch"):
- pass
- assert (tmp_path / "arch").exists()
-
-
-def test_buildenviron_windows(tmp_path):
- be = cibuild.BuildEnviron(
- system="Windows",
- root_dir=root,
- tag="v0.0.1",
- )
- assert be.platform_tag == "windows"
- assert be.archive_path == be.dist_dir / "mitmproxy-0.0.1-windows.zip"
-
- with be.archive(tmp_path / "arch"):
- pass
- assert (tmp_path / "arch").exists()
-
-
-@pytest.mark.parametrize(
- "version, tag, ok",
- [
- ("3.0.0.dev", "", True), # regular snapshot
- ("3.0.0.dev", "v3.0.0", False), # forgot to remove ".dev" on bump
- ("3.0.0", "", False), # forgot to re-add ".dev"
- ("3.0.0", "v4.0.0", False), # version mismatch
- ("3.0.0", "v3.0.0", True), # regular release
- ("3.0.0.rc1", "v3.0.0.rc1", False), # non-canonical.
- ("3.0.0.dev", "anyname", True), # tagged test/dev release
- ("3.0.0", "3.0.0", False), # tagged, but without v prefix
- ],
-)
-def test_buildenviron_check_version(version, tag, ok, tmpdir):
- tmpdir.mkdir("mitmproxy").join("version.py").write(f'VERSION = "{version}"')
-
- be = cibuild.BuildEnviron(
- root_dir=tmpdir,
- system="Windows",
- tag=tag,
- )
- if ok:
- be.check_version()
- else:
- with pytest.raises(ValueError):
- be.check_version()
-
-
-def test_bool_from_env(monkeypatch):
- monkeypatch.setenv("FOO", "1")
- assert cibuild.bool_from_env("FOO")
-
- monkeypatch.setenv("FOO", "0")
- assert not cibuild.bool_from_env("FOO")
-
- monkeypatch.setenv("FOO", "false")
- assert not cibuild.bool_from_env("FOO")
-
- monkeypatch.setenv("FOO", "")
- assert not cibuild.bool_from_env("FOO")
-
- monkeypatch.delenv("FOO")
- assert not cibuild.bool_from_env("FOO")
|