Skip to content

Commit

Permalink
adding app_globals test.
Browse files Browse the repository at this point in the history
  • Loading branch information
toumorokoshi committed Feb 25, 2016
1 parent e061ce1 commit 3ad34b4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
]

setup(name='uranium',
version='0.2.28b',
version='0.2.29',
description='a build system for python',
long_description=open('README.rst').read(),
author='Yusuke Tsutsumi',
Expand Down
20 changes: 20 additions & 0 deletions tests/test_app_globals_full.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
URANIUM_PY = """
from uranium import current_build
@current_build.task
def main(build):
print("ok")
"""
from uranium.scripts import execute_script
from .conftest import URANIUM_SOURCE_ROOT


def test_current_build_in_ubuild(tmpdir):
""" current_build shoud be valid in the ubuild.py """
tmpdir.join("ubuild.py").write(URANIUM_PY)

status, out, err = execute_script(
"uranium_standalone", "--uranium-dir", URANIUM_SOURCE_ROOT,
cwd=tmpdir.strpath
)
assert "ok" in out.decode("utf-8")
2 changes: 2 additions & 0 deletions uranium/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# we import setuptools to ensure it's provided
# when attempting to use uranium within a sandbox.
import setuptools
# same with markerlib
import _markerlib

from .remote import get_remote_script
from .decorators import task_requires
Expand Down
3 changes: 2 additions & 1 deletion uranium/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ def _run_script(self, path, task_name, override_func=None):
execute this function (passing in the script object) instead
of executing the task_name.
"""
script = build_script(path, {"build": self})
with self.as_current_build():
script = build_script(path, {"build": self})

if override_func:
return override_func(script)
Expand Down

0 comments on commit 3ad34b4

Please sign in to comment.