Skip to content

Commit

Permalink
Merge pull request #6024 from edx/clytwynec/fix_no_prereq_install
Browse files Browse the repository at this point in the history
fix NO_PREREQ_INSTALL
  • Loading branch information
Christine Lytwynec committed Nov 21, 2014
2 parents 73dd6fe + e9e5957 commit 7b36645
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 4 deletions.
40 changes: 40 additions & 0 deletions pavelib/paver_tests/test_prereqs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

import os
import unittest
from pavelib.prereqs import no_prereq_install


class TestPaverPrereqInstall(unittest.TestCase):

def check_val(self, set_val, expected_val):
_orig_environ = dict(os.environ)
os.environ['NO_PREREQ_INSTALL'] = set_val
self.assertEqual(
no_prereq_install(),
expected_val,
'NO_PREREQ_INSTALL is set to {}, but we read it as {}'.format(
set_val, expected_val),
)

# Reset Environment back to original state
os.environ.clear()
os.environ.update(_orig_environ)

def test_no_prereq_install_true(self):
self.check_val('true', True)

def test_no_prereq_install_false(self):
self.check_val('false', False)

def test_no_prereq_install_True(self):
self.check_val('True', True)

def test_no_prereq_install_False(self):
self.check_val('False', False)

def test_no_prereq_install_0(self):
self.check_val('0', False)

def test_no_prereq_install_1(self):
self.check_val('1', True)

27 changes: 23 additions & 4 deletions pavelib/prereqs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@
PYTHON_REQ_FILES.append(PRIVATE_REQS)


def no_prereq_install():
"""
Determine if NO_PREREQ_INSTALL should be truthy or falsy.
"""
vals = {
'0': False,
'1': True,
'true': True,
'false': False,
}

val = os.environ.get("NO_PREREQ_INSTALL", 'False').lower()

try:
return vals[val]
except:
return False


def compute_fingerprint(path_list):
"""
Hash the contents of all the files and directories in `path_list`.
Expand Down Expand Up @@ -123,7 +142,7 @@ def install_ruby_prereqs():
"""
Installs Ruby prereqs
"""
if os.environ.get("NO_PREREQ_INSTALL", False):
if no_prereq_install():
return

prereq_cache("Ruby prereqs", ["Gemfile"], ruby_prereqs_installation)
Expand All @@ -134,7 +153,7 @@ def install_node_prereqs():
"""
Installs Node prerequisites
"""
if os.environ.get("NO_PREREQ_INSTALL", False):
if no_prereq_install():
return

prereq_cache("Node prereqs", ["package.json"], node_prereqs_installation)
Expand All @@ -145,7 +164,7 @@ def install_python_prereqs():
"""
Installs Python prerequisites
"""
if os.environ.get("NO_PREREQ_INSTALL", False):
if no_prereq_install():
return

prereq_cache("Python prereqs", PYTHON_REQ_FILES + [sysconfig.get_python_lib()], python_prereqs_installation)
Expand All @@ -156,7 +175,7 @@ def install_prereqs():
"""
Installs Ruby, Node and Python prerequisites
"""
if os.environ.get("NO_PREREQ_INSTALL", False):
if no_prereq_install():
return

install_ruby_prereqs()
Expand Down

0 comments on commit 7b36645

Please sign in to comment.