aboutsummaryrefslogtreecommitdiffstats
path: root/test/release/test_cibuild.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2018-06-02 21:37:44 +0200
committerThomas Kriechbaumer <Kriechi@users.noreply.github.com>2018-06-02 21:37:44 +0200
commit09ff5df2fb354a017afa02138b329e615a80c1d0 (patch)
tree0472075396fdd789fab280eda2d82de294ee2146 /test/release/test_cibuild.py
parent28bd1275b2f04b02cf71146d96eadc331744e39f (diff)
downloadmitmproxy-09ff5df2fb354a017afa02138b329e615a80c1d0.tar.gz
mitmproxy-09ff5df2fb354a017afa02138b329e615a80c1d0.tar.bz2
mitmproxy-09ff5df2fb354a017afa02138b329e615a80c1d0.zip
Such CI, Very Wow. (#3182)
Diffstat (limited to 'test/release/test_cibuild.py')
-rw-r--r--test/release/test_cibuild.py136
1 files changed, 74 insertions, 62 deletions
diff --git a/test/release/test_cibuild.py b/test/release/test_cibuild.py
index 78ddf998..efa2f072 100644
--- a/test/release/test_cibuild.py
+++ b/test/release/test_cibuild.py
@@ -1,5 +1,5 @@
-import os
import io
+import os
import pytest
@@ -13,11 +13,9 @@ def test_buildenviron_live():
def test_buildenviron_common():
be = cibuild.BuildEnviron(
- system = "Linux",
- root_dir = "/foo",
-
- travis_tag = "v0.0.1",
- travis_branch = "v0.x",
+ system="Linux",
+ root_dir="/foo",
+ travis_branch="master",
)
assert be.release_dir == os.path.join(be.root_dir, "release")
assert be.dist_dir == os.path.join(be.root_dir, "release", "dist")
@@ -30,8 +28,8 @@ def test_buildenviron_common():
assert cs.getvalue()
be = cibuild.BuildEnviron(
- system = "Unknown",
- root_dir = "/foo",
+ system="Unknown",
+ root_dir="/foo",
)
with pytest.raises(cibuild.BuildError):
be.version
@@ -43,19 +41,18 @@ def test_buildenviron_pr():
# Simulates a PR. We build everything, but don't have access to secret
# credential env variables.
be = cibuild.BuildEnviron(
- travis_tag = "",
- travis_branch = "master",
- travis_pull_request = "true",
-
- should_build_wheel = True,
- should_build_pyinstaller = True,
- should_build_docker = True,
+ travis_tag="",
+ travis_branch="master",
+ travis_pull_request="true",
+ should_build_wheel=True,
+ should_build_pyinstaller=True,
+ should_build_docker=True,
)
assert be.is_pull_request
# Mini test for appveyor
be = cibuild.BuildEnviron(
- appveyor_pull_request_number = "xxxx",
+ appveyor_pull_request_number="xxxx",
)
assert be.is_pull_request
assert not be.is_prod_release
@@ -64,15 +61,14 @@ def test_buildenviron_pr():
def test_buildenviron_commit():
# Simulates an ordinary commit on the master branch.
be = cibuild.BuildEnviron(
- travis_tag = "",
- travis_branch = "master",
- travis_pull_request = "false",
-
- should_build_wheel = True,
- should_build_pyinstaller = True,
- should_build_docker = True,
- docker_username = "foo",
- docker_password = "bar",
+ travis_tag="",
+ travis_branch="master",
+ travis_pull_request="false",
+ should_build_wheel=True,
+ should_build_pyinstaller=True,
+ should_build_docker=True,
+ docker_username="foo",
+ docker_password="bar",
)
assert be.docker_tag == "mitmproxy/mitmproxy:dev"
assert be.should_upload_docker
@@ -81,23 +77,21 @@ def test_buildenviron_commit():
assert not be.is_prod_release
-def test_buildenviron_rleasetag():
+def test_buildenviron_releasetag():
# Simulates a tagged release on a release branch.
be = cibuild.BuildEnviron(
- system = "Linux",
- root_dir = "/foo",
-
- travis_tag = "v0.0.1",
- travis_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",
+ system="Linux",
+ root_dir="/foo",
+ travis_tag="0.0.1",
+ travis_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 == "v0.0.1"
+ assert be.tag == "0.0.1"
assert be.branch == "v0.x"
assert be.version == "0.0.1"
assert be.upload_dir == "0.0.1"
@@ -110,18 +104,16 @@ def test_buildenviron_rleasetag():
def test_buildenviron_branch():
# Simulates a development branch on the main repo
be = cibuild.BuildEnviron(
- system = "Linux",
- root_dir = "/foo",
-
- travis_tag = "",
- travis_branch = "mybranch",
-
- should_build_wheel = True,
- should_build_docker = True,
- should_build_pyinstaller = True,
- has_twine_creds = True,
- docker_username = "foo",
- docker_password = "bar",
+ system="Linux",
+ root_dir="/foo",
+ travis_tag="",
+ travis_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 == ""
assert be.branch == "mybranch"
@@ -133,11 +125,10 @@ def test_buildenviron_branch():
def test_buildenviron_osx(tmpdir):
be = cibuild.BuildEnviron(
- system = "Darwin",
- root_dir = "/foo",
-
- travis_tag = "v0.0.1",
- travis_branch = "v0.x",
+ system="Darwin",
+ root_dir="/foo",
+ travis_tag="0.0.1",
+ travis_branch="v0.x",
)
assert be.platform_tag == "osx"
assert be.bdists == {
@@ -153,11 +144,10 @@ def test_buildenviron_osx(tmpdir):
def test_buildenviron_windows(tmpdir):
be = cibuild.BuildEnviron(
- system = "Windows",
- root_dir = "/foo",
-
- travis_tag = "v0.0.1",
- travis_branch = "v0.x",
+ system="Windows",
+ root_dir="/foo",
+ travis_tag="0.0.1",
+ travis_branch="v0.x",
)
assert be.platform_tag == "windows"
assert be.bdists == {
@@ -168,4 +158,26 @@ def test_buildenviron_windows(tmpdir):
a = be.archive(os.path.join(tmpdir, "arch"))
assert a
- a.close() \ No newline at end of file
+ a.close()
+
+
+@pytest.mark.parametrize("version, tag, ok", [
+ ("3.0.0.dev", "", True), # regular snapshot
+ ("3.0.0.dev", "3.0.0", False), # forgot to remove ".dev" on bump
+ ("3.0.0", "", False), # forgot to re-add ".dev"
+ ("3.0.0", "4.0.0", False), # version mismatch
+ ("3.0.0", "3.0.0", True), # regular release
+ ("3.0.0.rc1", "3.0.0.rc1", False), # non-canonical.
+])
+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,
+ travis_tag=tag
+ )
+ if ok:
+ be.check_version()
+ else:
+ with pytest.raises(ValueError):
+ be.check_version()