aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/test/test_llmanifest.py
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:50 -0500
committerJacek Antonelli2008-08-15 23:44:50 -0500
commit89fe5dab825a62a0e3fd8d248cbc91c65eb2a426 (patch)
treebcff14b7888d04a2fec799c59369f6095224bd08 /linden/indra/test/test_llmanifest.py
parentSecond Life viewer sources 1.13.3.2 (diff)
downloadmeta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.zip
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.gz
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.bz2
meta-impy-89fe5dab825a62a0e3fd8d248cbc91c65eb2a426.tar.xz
Second Life viewer sources 1.14.0.0
Diffstat (limited to 'linden/indra/test/test_llmanifest.py')
-rw-r--r--linden/indra/test/test_llmanifest.py128
1 files changed, 128 insertions, 0 deletions
diff --git a/linden/indra/test/test_llmanifest.py b/linden/indra/test/test_llmanifest.py
new file mode 100644
index 0000000..b20b6c1
--- /dev/null
+++ b/linden/indra/test/test_llmanifest.py
@@ -0,0 +1,128 @@
1#!/usr/bin/python
2# @file test_llmanifest.py
3# @author Ryan Williams
4# @brief Test cases for LLManifest library.
5#
6# Copyright (c) 2006-2007, Linden Research, Inc.
7#
8# The source code in this file ("Source Code") is provided by Linden Lab
9# to you under the terms of the GNU General Public License, version 2.0
10# ("GPL"), unless you have obtained a separate licensing agreement
11# ("Other License"), formally executed by you and Linden Lab. Terms of
12# the GPL can be found in doc/GPL-license.txt in this distribution, or
13# online at http://secondlife.com/developers/opensource/gplv2
14#
15# There are special exceptions to the terms and conditions of the GPL as
16# it is applied to this Source Code. View the full text of the exception
17# in the file doc/FLOSS-exception.txt in this software distribution, or
18# online at http://secondlife.com/developers/opensource/flossexception
19#
20# By copying, modifying or distributing this software, you acknowledge
21# that you have read and understood your obligations described above,
22# and agree to abide by those obligations.
23#
24# ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25# WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26# COMPLETENESS OR PERFORMANCE.
27
28from indra import llmanifest
29import os.path
30import os
31import unittest
32
33class DemoManifest(llmanifest.LLManifest):
34 def construct(self):
35 super(DemoManifest, self).construct()
36 if self.prefix("dir_1"):
37 self.path("test_a")
38 self.path(src="test_b", dst="test_dst_b")
39 self.path("*.test")
40 self.path("*.tex", "*.jpg")
41 if self.prefix("nested", dst=""):
42 self.path("deep")
43 self.end_prefix()
44 self.end_prefix("dir_1")
45
46
47class Demo_ArchManifest(llmanifest.LLManifest):
48 pass
49
50class TestLLManifest(unittest.TestCase):
51 mode='static'
52 def setUp(self):
53 self.m = llmanifest.LLManifest("src", "dst", {'grid':'default', 'platform':'darwin', 'version':(1,2,3,4)})
54
55 def testproperwindowspath(self):
56 self.assertEqual(llmanifest.proper_windows_path("C:\Program Files", "cygwin"),"/cygdrive/c/Program Files")
57 self.assertEqual(llmanifest.proper_windows_path("C:\Program Files", "windows"), "C:\Program Files")
58 self.assertEqual(llmanifest.proper_windows_path("/cygdrive/c/Program Files/NSIS", "windows"), "C:\Program Files\NSIS")
59 self.assertEqual(llmanifest.proper_windows_path("/cygdrive/c/Program Files/NSIS", "cygwin"), "/cygdrive/c/Program Files/NSIS")
60
61 def testpathancestors(self):
62 self.assertEqual(["dir"], [p for p in llmanifest.path_ancestors("dir")])
63 self.assertEqual(["dir/sub", "dir"], [p for p in llmanifest.path_ancestors("dir/sub")])
64 self.assertEqual(["dir/sub", "dir"], [p for p in llmanifest.path_ancestors("dir/sub/")])
65 self.assertEqual(["dir/sub/two", "dir/sub", "dir"], [p for p in llmanifest.path_ancestors("dir/sub/two")])
66
67
68 def testforplatform(self):
69 self.assertEqual(llmanifest.LLManifest.for_platform('demo'), DemoManifest)
70 def tmp_test():
71 return llmanifest.LLManifest.for_platform('extant')
72 self.assertRaises(KeyError, tmp_test)
73 ExtantManifest = llmanifest.LLManifestRegistry('ExtantManifest', (llmanifest.LLManifest,), {})
74 self.assertEqual(llmanifest.LLManifest.for_platform('extant'), ExtantManifest)
75 self.assertEqual(llmanifest.LLManifest.for_platform('demo', 'Arch'), Demo_ArchManifest)
76
77
78 def testprefix(self):
79 self.assertEqual(self.m.get_src_prefix(), "src")
80 self.assertEqual(self.m.get_dst_prefix(), "dst")
81 self.m.prefix("level1")
82 self.assertEqual(self.m.get_src_prefix(), "src/level1")
83 self.assertEqual(self.m.get_dst_prefix(), "dst/level1")
84 self.m.end_prefix()
85 self.m.prefix(src="src", dst="dst")
86 self.assertEqual(self.m.get_src_prefix(), "src/src")
87 self.assertEqual(self.m.get_dst_prefix(), "dst/dst")
88 self.m.end_prefix()
89
90 def testendprefix(self):
91 self.assertEqual(self.m.get_src_prefix(), "src")
92 self.assertEqual(self.m.get_dst_prefix(), "dst")
93 self.m.prefix("levela")
94 self.m.end_prefix()
95 self.assertEqual(self.m.get_src_prefix(), "src")
96 self.assertEqual(self.m.get_dst_prefix(), "dst")
97 self.m.prefix("level1")
98 self.m.end_prefix("level1")
99 self.assertEqual(self.m.get_src_prefix(), "src")
100 self.assertEqual(self.m.get_dst_prefix(), "dst")
101 self.m.prefix("level1")
102 def tmp_test():
103 self.m.end_prefix("mismatch")
104 self.assertRaises(ValueError, tmp_test)
105
106 def testruncommand(self):
107 self.assertEqual("Hello\n", self.m.run_command("echo Hello"))
108 def tmp_test():
109 self.m.run_command("fff_garbage")
110 self.assertRaises(RuntimeError, tmp_test)
111
112 def testpathof(self):
113 self.assertEqual(self.m.src_path_of("a"), "src/a")
114 self.assertEqual(self.m.dst_path_of("a"), "dst/a")
115 self.m.prefix("tmp")
116 self.assertEqual(self.m.src_path_of("b/c"), "src/tmp/b/c")
117 self.assertEqual(self.m.dst_path_of("b/c"), "dst/tmp/b/c")
118
119 def testcmakedirs(self):
120 self.m.cmakedirs("test_dir_DELETE/nested/dir")
121 self.assert_(os.path.exists("test_dir_DELETE/nested/dir"))
122 self.assert_(os.path.isdir("test_dir_DELETE"))
123 self.assert_(os.path.isdir("test_dir_DELETE/nested"))
124 self.assert_(os.path.isdir("test_dir_DELETE/nested/dir"))
125 os.removedirs("test_dir_DELETE/nested/dir")
126
127if __name__ == '__main__':
128 unittest.main()