summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--morphlib/builder.py6
-rw-r--r--morphlib/util.py9
-rw-r--r--morphlib/util_tests.py8
3 files changed, 18 insertions, 5 deletions
diff --git a/morphlib/builder.py b/morphlib/builder.py
index 76c234a6..bc51ab19 100644
--- a/morphlib/builder.py
+++ b/morphlib/builder.py
@@ -52,10 +52,6 @@ class Builder(object):
self.settings = settings
self.cachedir = morphlib.cachedir.CacheDir(settings['cachedir'])
- @property
- def arch(self):
- return os.uname()[4]
-
def build(self, morph):
'''Build a binary based on a morphology.'''
if morph.kind == 'chunk':
@@ -174,7 +170,7 @@ class Builder(object):
dict_key = {
'name': name,
'kind': kind,
- 'arch': self.arch,
+ 'arch': morphlib.util.arch(),
'repo': repo,
'ref': abs_ref,
}
diff --git a/morphlib/util.py b/morphlib/util.py
index 850d943f..430fdc20 100644
--- a/morphlib/util.py
+++ b/morphlib/util.py
@@ -17,6 +17,15 @@
'''Utility functions for morph.'''
+import os
+
+
+def arch():
+ '''Return the CPU architecture of the current host.'''
+ return os.uname()[4]
+
+
+
def indent(string, spaces=4):
'''Return ``string`` indented by ``spaces`` spaces.
diff --git a/morphlib/util_tests.py b/morphlib/util_tests.py
index 5b1d5e88..6637f571 100644
--- a/morphlib/util_tests.py
+++ b/morphlib/util_tests.py
@@ -19,6 +19,14 @@ import unittest
import morphlib
+class ArchTests(unittest.TestCase):
+
+ def test(self):
+ arch = morphlib.util.arch()
+ self.assertEqual(type(arch), str)
+ self.assertNotEqual(arch, '')
+
+
class IndentTests(unittest.TestCase):
def test_returns_empty_string_for_empty_string(self):