Beispiel #1
0
 def test_get_and_set_date_conf(self):
     with ioutil.TempDir() as td:
         sb = sandbox.layout(td.path, 'foo', 'trunk', 'official')
         now = time.time()
         sb._set_date_conf('info', 'x', now)
         when = sb._get_date_conf('info', 'x')
         self.assertEquals(now, when)
Beispiel #2
0
 def test_inherit_lock_fails_when_same_sandbox_already_locked(self):
     with ioutil.TempDir() as td:
         sb = sandbox.layout(td.path, 'foo', 'trunk', 'x')
         lock = sb.lock('test')
         try:
             lock2 = sb.try_to_inherit_lock()
             self.fail("Expected exception when trying to inherit a lock on a sandbox that's already locked.")
         except:
             pass
Beispiel #3
0
 def test_init_wont_accept_existing_file(self):
     with ioutil.TempDir() as td:
         tempFile = os.path.join(td.path, 'foo.trunk.dev')
         open(tempFile, 'w').close()
         try:
             x = sandbox.Sandbox(tempFile)
             ok = False
         except AssertionError:
             ok = True
     self.assertTrue(ok)
Beispiel #4
0
    def test_sadm_self_update(self):
        stdout = StringIO.StringIO()
        try:
            with ioutil.TempDir() as td:
                rundir = os.path.join(td.path, "run")
                # We are copying from <built root>/sadm instead of from <run root>, in case
                # sadm is ever not the top of the dependency hierarchy in a sandbox.
                shutil.copytree(
                    sandbox.current.get_component_path('sadm', 'built'),
                    rundir)

                def run(cmd, stdout):
                    stdout.write(cmd + '\n')
                    p = subprocess.Popen(cmd,
                                         shell=True,
                                         stdout=subprocess.PIPE,
                                         stderr=subprocess.STDOUT)
                    p.stdout.read()
                    p.wait()

                with ioutil.WorkingDir(rundir) as twd:
                    run('bzr init "%s"' % rundir, stdout)
                    run('bzr add', stdout)
                    run('bzr ci -m "initial commit"', stdout)
                    with ioutil.TempDir() as td2:
                        new_file = 'test-the-update-procedure'
                        run(
                            'bzr co --lightweight "%s" "%s"' %
                            (rundir, td2.path), stdout)
                        # make a change in master
                        open(os.path.join(rundir, new_file), "w").close()
                        run('bzr add', stdout)
                        run('bzr ci -m "second commit"', stdout)
                        run(
                            'python "%s/sadm.py" update --auto-confirm --test'
                            % td2.path, stdout)
                        self.assertTrue(
                            os.path.isfile(os.path.join(td2.path, new_file)))
        except:
            print(stdout.getvalue())
            import traceback
            traceback.print_exc()
Beispiel #5
0
 def test_inherit_lock(self):
     with ioutil.TempDir() as td:
         sb = sandbox.layout(td.path, 'foo', 'trunk', 'x')
         lock = sb.lock('test')
         sb2 = sandbox.Sandbox(sb.get_root())
         lock2 = sb2.try_to_inherit_lock()
         self.assertTrue(bool(lock2))
         self.assertTrue(lock2.inherited)
         self.assertFalse(lock.inherited)
         lock2.release()
         self.assertTrue(os.path.isfile(lock.path))
Beispiel #6
0
 def check_select_builder(self, fil, typ):
     with ioutil.TempDir() as td:
         sb = sandbox.Sandbox(td.path + '/foo.trunk.dev')
         sb.layout()
         os.makedirs(sb.get_code_root() + 'foo')
         aux_folder = sb.get_iftop_folder_path()
         os.makedirs(aux_folder)
         f = os.path.join(aux_folder, fil)
         #print('writing %s' % f)
         open(f, 'w').close()
         bld = build.select_builder(sb)
         self.assertEqual(typ, bld.get_name())
Beispiel #7
0
 def test_layout(self):
     with ioutil.TempDir() as td:
         sb = sandbox.layout(td.path, 'foo', 'trunk', 'dev')
         try:
             self.assertTrue(os.path.isdir(sb.get_code_root()))
             self.assertTrue(os.path.isdir(sb.get_built_root()))
             self.assertTrue(os.path.isdir(sb.get_test_root()))
             self.assertTrue(os.path.isdir(sb.get_root()))
             ok = True
         except AssertionError:
             ok = False
     if not ok:
         fail('Layout of sandbox at %s failed.' % sb.get_root())