Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-11-30 15:18:38 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-11-30 15:18:38 (GMT)
commit4f98fe10ea482fad3fffe9d655d26139dea30965 (patch)
tree4a780e780e20177e17a7c2f97477ed578f7af49b
parentf87c98e40b1ae61b889abe06db944b88433c0ada (diff)
Add more tests and fix bugs
-rw-r--r--config/modules/index.json4
-rw-r--r--devbot/config.py10
-rw-r--r--devbot/plugins/debian.py2
-rw-r--r--devbot/plugins/fedora.py4
-rw-r--r--devbot/plugins/ubuntu.py27
-rw-r--r--tests/devbot/data/os-release-ubuntu-12.106
-rw-r--r--tests/devbot/test_config.py45
7 files changed, 62 insertions, 36 deletions
diff --git a/config/modules/index.json b/config/modules/index.json
index c098f19..5317772 100644
--- a/config/modules/index.json
+++ b/config/modules/index.json
@@ -1,3 +1,3 @@
-["activities.json",
+["system.json",
"sugar.json",
- "system.json"]
+ "activities.json"]
diff --git a/devbot/config.py b/devbot/config.py
index a5f9428..4c04a56 100644
--- a/devbot/config.py
+++ b/devbot/config.py
@@ -233,7 +233,8 @@ def _filter_if(item):
return True
distro_info = distro.get_distro_info()
- globals = { "gstreamer_version": distro_info.gstreamer_version }
+ globals = { "gstreamer_version": distro_info.gstreamer_version,
+ "gnome_version": distro_info.gnome_version }
return eval(item["if"], globals)
@@ -248,15 +249,14 @@ def load_checks():
def load_modules():
module_dir = os.path.join(config_dir, "modules")
+ modules = []
with open(os.path.join(module_dir, "index.json")) as f:
- modules = []
for module_file in json.load(f):
path = os.path.join(module_dir, module_file)
-
for info in json.load(open(path)):
- modules.append(Module(info))
+ modules.append(info)
- return modules
+ return [Module(info) for info in filter(_filter_if, modules)]
def clean():
try:
diff --git a/devbot/plugins/debian.py b/devbot/plugins/debian.py
index 687ffad..eea0001 100644
--- a/devbot/plugins/debian.py
+++ b/devbot/plugins/debian.py
@@ -97,7 +97,7 @@ class DistroInfo(interfaces.DistroInfo):
self.use_lib64 = False
try:
- with open(_DEBIAN_VERSION_PATH) as f:
+ with open(self._DEBIAN_VERSION_PATH) as f:
debian_version = f.read()
except IOError:
debian_version = None
diff --git a/devbot/plugins/fedora.py b/devbot/plugins/fedora.py
index ebfc91a..27f1d17 100644
--- a/devbot/plugins/fedora.py
+++ b/devbot/plugins/fedora.py
@@ -96,11 +96,11 @@ class DistroInfo(interfaces.DistroInfo):
self.supported = (arch in ["i386", "i686", "x86_64"])
try:
- release = open(_FEDORA_RELEASE_PATH).read().strip()
+ release = open(self._FEDORA_RELEASE_PATH).read().strip()
except IOError:
release = None
self.valid = False
-
+
if release == "Fedora release 17 (Beefy Miracle)":
self.version = "17"
self.gnome_version = "3.4"
diff --git a/devbot/plugins/ubuntu.py b/devbot/plugins/ubuntu.py
index eaeb482..47379ac 100644
--- a/devbot/plugins/ubuntu.py
+++ b/devbot/plugins/ubuntu.py
@@ -7,6 +7,7 @@ from devbot.plugins import debian
distro.register_package_manager("ubuntu", debian.PackageManager)
class DistroInfo(interfaces.DistroInfo):
+ _OS_RELEASE_PATH="/etc/os-release"
def __init__(self):
arch = subprocess.check_output(["uname", "-i"]).strip()
@@ -17,11 +18,21 @@ class DistroInfo(interfaces.DistroInfo):
self.valid = True
self.supported = (arch in ["i386", "i686", "x86_64"])
self.use_lib64 = False
+
+ try:
+ release = open(self._OS_RELEASE_PATH).read().strip()
+ os_info = {}
+ for line in release.split("\n"):
+ split = line.strip().split("=")
+ os_info[split[0]] = split[1].replace("\"", "")
+ except IOError:
+ release = None
+ self.valid = False
- if self._get_distributor() != "Ubuntu":
+ if os_info["ID"] != "ubuntu":
self.valid = False
- self.version = self._get_release()
+ self.version = os_info.get("VERSION_ID", None)
if self.version != "12.10":
self.supported = False
@@ -29,16 +40,4 @@ class DistroInfo(interfaces.DistroInfo):
if self.version and self.version >= "12.10":
self.gnome_version = "3.6"
- def _get_distributor(self):
- try:
- return subprocess.check_output(["lsb_release", "-si"]).strip()
- except OSError:
- None
-
- def _get_release(self):
- try:
- return subprocess.check_output(["lsb_release", "-sr"]).strip()
- except OSError:
- return None
-
distro.register_distro_info(DistroInfo)
diff --git a/tests/devbot/data/os-release-ubuntu-12.10 b/tests/devbot/data/os-release-ubuntu-12.10
new file mode 100644
index 0000000..9b53281
--- /dev/null
+++ b/tests/devbot/data/os-release-ubuntu-12.10
@@ -0,0 +1,6 @@
+NAME="Ubuntu"
+VERSION="12.10, Quantal Quetzal"
+ID=ubuntu
+ID_LIKE=debian
+PRETTY_NAME="Ubuntu quantal (12.10)"
+VERSION_ID="12.10"
diff --git a/tests/devbot/test_config.py b/tests/devbot/test_config.py
index 2c3f2fa..39b3f65 100644
--- a/tests/devbot/test_config.py
+++ b/tests/devbot/test_config.py
@@ -13,27 +13,34 @@ config_dir = os.path.join(base_dir, "config")
data_dir = os.path.join(tests_dir, "data")
class TestConfig(unittest.TestCase):
- def setUp(self):
- config.set_config_dir(config_dir)
-
def _set_distro(self, name, version):
- self._orig_supported_distro = distro._supported_distros
+ if config.config_dir is None:
+ config.set_config_dir(config_dir)
+ config.load_plugins()
+
+ self._orig = distro._supported_distros
for info_class in distro._supported_distros:
- if "_FEDORA_RELEASE_PATH" in distro_info_class:
+ if info_class.__module__.endswith("fedora"):
info_class._FEDORA_RELEASE_PATH = \
- os.path.join(data_dir, "fedora-release-18")
+ os.path.join(data_dir, "fedora-release-%s" % version)
- if "_DEBIAN_VERSION_PATH" in distro_info_class:
+ if info_class.__module__.endswith("debian"):
info_class._DEBIAN_VERSION_PATH = \
os.path.join(data_dir, "debian_version-wheezy")
+ if info_class.__module__.endswith("ubuntu"):
+ info_class._OS_RELEASE_PATH = \
+ os.path.join(data_dir, "os-release-ubuntu-12.10")
+
+ for info_class in distro._supported_distros:
info = info_class()
if info.name == name and info.version == version:
- self._supported_distros = [info]
+ distro._supported_distros = [info_class]
+ distro._distro_info = None
break
def _unset_distro(self):
- distro._supported_distros = self._orig_supported_distro
+ distro._supported_distros = self._orig
def _find_module(self, modules, name):
for module in modules:
@@ -46,7 +53,7 @@ class TestConfig(unittest.TestCase):
self.assertIsNotNone(self._find_module(modules, name))
def _assert_no_module(self, modules, name):
- self.assertIsNotNone(self._find_module(modules, name))
+ self.assertIsNone(self._find_module(modules, name))
def test_fedora_17_modules(self):
self._set_distro("fedora", "17")
@@ -62,10 +69,24 @@ class TestConfig(unittest.TestCase):
def test_fedora_18_modules(self):
self._set_distro("fedora", "18")
+
+ self.assertEquals("fedora", distro.get_distro_info().name)
+ self.assertEquals("18", distro.get_distro_info().version)
modules = config.load_modules()
self._assert_module(modules, "glib")
- self._assert_module(modules, "gtk+")
- self._assert_module(modules, "gstreamer")
+ self._assert_no_module(modules, "gtk+")
+ self._assert_no_module(modules, "gstreamer")
+ self._assert_module(modules, "sugar")
+
+ self._unset_distro()
+
+ def test_ubuntu_12_10_modules(self):
+ self._set_distro("ubuntu", "12.10")
+
+ modules = config.load_modules()
+ self._assert_module(modules, "glib")
+ self._assert_no_module(modules, "gtk+")
+ self._assert_no_module(modules, "gstreamer")
self._assert_module(modules, "sugar")
self._unset_distro()