Beispiel #1
0
 def test_add_project(self):
     xml = "<worktree />"
     worktree = self.create_worktee(xml)
     worktree.add_project("foo")
     self.assertEquals(len(worktree.projects), 1)
     foo = worktree.get_project("foo")
     self.assertEquals(foo.src, "foo")
Beispiel #2
0
    def test_nested_worktrees(self):
        # Create a worktree in work, with a project named
        # foo
        work = os.path.join(self.tmp, "work")
        qisys.sh.mkdir(work)
        worktree = qisys.worktree.create(work)
        foo = os.path.join(work, "foo")
        qisys.sh.mkdir(foo)
        worktree.add_project(foo)
        foo_test = os.path.join(foo, "test")
        qisys.sh.mkdir(foo_test)

        # Try to create a worktree in foo/test: should
        # do nothing
        test_worktree = qisys.worktree.create(foo_test)
        test_dot_qi = os.path.join(foo_test, ".qi")
        self.assertFalse(os.path.exists(test_dot_qi))
        worktree2 = qisys.worktree.open_worktree(work)
        worktree2.get_project("foo")

        # Use the force:
        worktree3 = qisys.worktree.create(foo_test, force=True)
        self.assertEquals(worktree3.projects, list())

        # Try to create a worktree in the same place should not raise
        worktree4 = qisys.worktree.create(work)
Beispiel #3
0
def test_add_project_simple(worktree):
    # pylint: disable-msg=E1101
    tmp = py.path.local(worktree.root)
    tmp.mkdir("foo")
    worktree.add_project("foo")
    assert len(worktree.projects) == 1
    foo = worktree.get_project("foo")
    assert foo.src == "foo"
Beispiel #4
0
def test_add_project_simple(worktree):
    # pylint: disable-msg=E1101
    tmp = py.path.local(worktree.root)
    tmp.mkdir("foo")
    worktree.add_project("foo")
    assert len(worktree.projects) == 1
    foo = worktree.get_project("foo")
    assert foo.src == "foo"
Beispiel #5
0
def test_add_project_simple(worktree):
    """ Test Add Project Simple """
    tmp = py.path.local(worktree.root)  # pylint:disable=no-member
    tmp.mkdir("foo")
    worktree.add_project("foo")
    assert len(worktree.projects) == 1
    foo1 = worktree.get_project("foo")
    assert foo1.src == "foo"
Beispiel #6
0
def test_ignore_src_dot(tmpdir):
    foo_path = tmpdir.mkdir("foo")
    tmpdir.join("foo", "qiproject.xml").write("""
<project>
  <project src="." />
</project>
""")
    worktree = qisys.worktree.WorkTree(tmpdir.strpath)
    worktree.add_project("foo")
Beispiel #7
0
def test_ignore_src_dot(tmpdir):
    foo_path = tmpdir.mkdir("foo")
    tmpdir.join("foo", "qiproject.xml").write("""
<project>
  <project src="." />
</project>
""")
    worktree  = qisys.worktree.WorkTree(tmpdir.strpath)
    worktree.add_project("foo")
Beispiel #8
0
    def test_add_git_project(self):
        xml = "<worktree />"
        worktree = self.create_worktee(xml)
        worktree.add_project("foo")
        qisys.sh.mkdir(
            os.path.join(self.tmp, "foo", ".git"),
            recursive=True)

        # Re-open worktre, check that foo is in git_projects
        worktree = qisys.worktree.open_worktree(self.tmp)
        self.assertEquals(len(worktree.git_projects), 1)
        git_foo = worktree.get_project("foo")
        self.assertEquals(git_foo.src, "foo")
Beispiel #9
0
 def test_remove_project(self):
     xml = "<worktree />"
     worktree = self.create_worktee(xml)
     foo_src = os.path.join(worktree.root, "foo")
     qisys.sh.mkdir(foo_src)
     worktree.add_project("foo")
     self.assertEquals(len(worktree.projects), 1)
     foo = worktree.get_project("foo")
     self.assertEquals(foo.src, "foo")
     error = None
     try:
         worktree.remove_project("bar")
     except Exception, e:
         error = e
Beispiel #10
0
def test_add_nested_projects(worktree):
    worktree.create_project("foo")
    tmpdir = worktree.tmpdir
    spam = tmpdir.mkdir("spam")
    spam.join("qiproject.xml").write(""" \
<project>
  <project src="eggs" />
</project>
""")
    spam.mkdir("eggs")
    worktree.add_project("spam")
    assert [p.src for p in worktree.projects] == ["foo", "spam", "spam/eggs"]

    worktree.remove_project("spam")
    assert [p.src for p in worktree.projects] == ["foo"]
Beispiel #11
0
def test_add_nested_projects(worktree):
    worktree.create_project("foo")
    tmpdir = worktree.tmpdir
    spam = tmpdir.mkdir("spam")
    spam.join("qiproject.xml").write(""" \
<project>
  <project src="eggs" />
</project>
""")
    spam.mkdir("eggs")
    worktree.add_project("spam")
    assert [p.src for p in worktree.projects] == ["foo", "spam", "spam/eggs"]

    worktree.remove_project("spam")
    assert [p.src for p in worktree.projects] == ["foo"]
Beispiel #12
0
def test_remove_project(worktree):
    """ Test Remove Project """
    tmp = py.path.local(worktree.root)  # pylint:disable=no-member
    foo_src = tmp.mkdir("foo")
    worktree.add_project("foo")
    with pytest.raises(qisys.worktree.WorkTreeError) as e:
        worktree.remove_project("bar")
    assert "No project in 'bar'" in e.value.message
    worktree.remove_project("foo")
    assert worktree.projects == list()
    worktree.add_project("foo")
    assert worktree.projects[0].src == "foo"
    worktree.remove_project("foo", from_disk=True)
    assert worktree.projects == list()
    assert not os.path.exists(foo_src.strpath)
Beispiel #13
0
def test_remove_project(worktree):
    # pylint: disable-msg=E1101
    tmp = py.path.local(worktree.root)
    foo_src = tmp.mkdir("foo")
    worktree.add_project("foo")
    # pylint: disable-msg=E1101
    with pytest.raises(qisys.worktree.WorkTreeError) as e:
        worktree.remove_project("bar")
    assert "No such project" in e.value.message

    worktree.remove_project("foo")
    assert worktree.projects == list()

    worktree.add_project("foo")
    assert worktree.projects[0].src == "foo"

    worktree.remove_project("foo", from_disk=True)
    assert worktree.projects == list()
    assert not os.path.exists(foo_src.strpath)
Beispiel #14
0
def test_remove_project(worktree):
    # pylint: disable-msg=E1101
    tmp = py.path.local(worktree.root)
    foo_src = tmp.mkdir("foo")
    worktree.add_project("foo")
    # pylint: disable-msg=E1101
    with pytest.raises(qisys.worktree.WorkTreeError) as e:
        worktree.remove_project("bar")
    assert "No such project" in e.value.message

    worktree.remove_project("foo")
    assert worktree.projects == list()

    worktree.add_project("foo")
    assert worktree.projects[0].src == "foo"

    worktree.remove_project("foo", from_disk=True)
    assert worktree.projects == list()
    assert not os.path.exists(foo_src.strpath)
Beispiel #15
0
def create_worktree(tmpdir):
    """ Helper function: Create a nice worktree with
    several git projects

    """
    worktree = qisys.worktree.create(tmpdir.strpath)
    my_gui = tmpdir.mkdir("gui").mkdir("my_gui")
    worktree.add_project(my_gui.strpath)
    lib = tmpdir.mkdir("lib")
    lib_foo = lib.mkdir("libfoo")
    lib_foo.mkdir("src")
    worktree.add_project(lib_foo.strpath)
    lib_bar = lib.mkdir("libbar")
    lib_bar.mkdir("src")
    worktree.add_project(lib_bar.strpath)
    spam = tmpdir.mkdir("spam")
    worktree.add_project(spam.strpath)
    eggs = spam.mkdir("eggs")
    worktree.add_project(eggs.strpath)
    tmpdir.mkdir("other")
    return worktree
Beispiel #16
0
def find_or_add(worktree, cwd=None):
    """
    If we find a qiproject.xml in a path not registered yet by looking
    in the parent directories, we just add it to the list.
    """
    if cwd is None:
        cwd = os.getcwd()
    head = cwd
    tail = None
    while True:
        candidate = os.path.join(head, "qiproject.xml")
        project = worktree.get_project(head)
        if project:
            return project
        if os.path.exists(candidate):
            return worktree.add_project(head)
        (head, tail) = os.path.split(head)
        if not tail:
            break
Beispiel #17
0
def find_or_add(worktree, cwd=None):
    """
    If we find a qiproject.xml in a path not registered yet by looking
    in the parent directories, we just add it to the list.
    """
    if cwd is None:
        cwd = os.getcwd()
    head = cwd
    tail = None
    while True:
        candidate = os.path.join(head, "qiproject.xml")
        project = worktree.get_project(head)
        if project:
            return project
        if os.path.exists(candidate):
            return worktree.add_project(head)
        (head, tail) = os.path.split(head)
        if not tail:
            break