Skip to content

Commit

Permalink
Fix Upload only when stable
Browse files Browse the repository at this point in the history
Signed-off-by: Uilian Ries <[email protected]>
  • Loading branch information
uilianries committed Nov 14, 2018
1 parent 264e192 commit d6ff9e5
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bincrafters/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.17.5'
__version__ = '0.17.6'
6 changes: 5 additions & 1 deletion bincrafters/build_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
from cpt.tools import split_colon_env


def get_bool_from_env(var_name, default="1"):
val = os.getenv(var_name, default)
return str(val).lower() in ("1", "true", "yes", "y")

def get_value_from_recipe(search_string, recipe="conanfile.py"):
with open(recipe, "r") as conanfile:
contents = conanfile.read()
Expand Down Expand Up @@ -114,7 +118,7 @@ def get_conan_remotes(username):


def get_upload_when_stable():
return os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", True)
return get_bool_from_env("CONAN_UPLOAD_ONLY_WHEN_STABLE")


def get_os():
Expand Down
29 changes: 23 additions & 6 deletions tests/test_package_tools.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import platform
import pytest
from bincrafters import build_shared
from bincrafters import build_template_boost_default
from bincrafters import build_template_boost_header_only
from bincrafters import build_template_default
from bincrafters import build_template_header_only
from bincrafters import build_template_installer
import os
import platform
import pytest


@pytest.fixture(autouse=True)
Expand All @@ -31,6 +31,13 @@ def set_minimal_build_environment():
del os.environ["CONAN_BUILD_TYPES"]


@pytest.fixture()
def set_upload_when_stable_false():
os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"] = "0"
yield
del os.environ["CONAN_UPLOAD_ONLY_WHEN_STABLE"]


def test_build_template_boost_default():
builder = build_template_boost_default.get_builder()

Expand All @@ -47,7 +54,7 @@ def test_build_template_boost_default():
elif platform.system() == "Darwin":
assert 4 == len(builder.items)

assert builder.upload_only_when_stable == ""
assert False == builder.upload_only_when_stable


def test_build_template_default():
Expand All @@ -64,7 +71,7 @@ def test_build_template_default():
elif platform.system() == "Darwin":
assert 4 == len(builder.items)

assert builder.upload_only_when_stable
assert True == builder.upload_only_when_stable


def test_build_template_default_minimal(set_minimal_build_environment):
Expand Down Expand Up @@ -118,7 +125,7 @@ def test_build_boost_header_only():
for settings, options, env_vars, build_requires, reference in builder.items:
assert 0 == len(options)
assert 1 == len(builder.items)
assert builder.upload_only_when_stable == ""
assert builder.upload_only_when_stable == False


def test_get_os():
Expand All @@ -144,3 +151,13 @@ def test_build_policy_set_in_args():
def test_build_policy_set_header_only():
builder = build_template_header_only.get_builder(build_policy='missing')
assert 'missing' == builder.build_policy


def test_upload_only_when_stable_builder(set_upload_when_stable_false):
builder = build_template_default.get_builder()
assert False == builder.upload_only_when_stable


def test_upload_only_when_stable_header_only(set_upload_when_stable_false):
builder = build_template_header_only.get_builder()
assert False == builder.upload_only_when_stable

0 comments on commit d6ff9e5

Please sign in to comment.