Support absolute paths

Change-Id: Ibe087d2bad0c6c9f1619d8811103415bcb3b4906
diff --git a/tests/ls.cpp b/tests/ls.cpp
index c2cc5fe..9356c69 100644
--- a/tests/ls.cpp
+++ b/tests/ls.cpp
@@ -41,8 +41,75 @@
 
         SECTION("with path argument")
         {
-            input = "ls example:a";
-            expected.m_path = path_{{node_(module_{"example"}, container_{"a"})}};
+            SECTION("ls example:a")
+            {
+                input = "ls example:a";
+                expected.m_path = path_{Scope::Relative, {node_(module_{"example"}, container_{"a"})}};
+            }
+
+            SECTION("ls /example:a")
+            {
+                SECTION("cwd: /") {}
+                SECTION("cwd: /example:a") {parser.changeNode(path_{Scope::Relative, {node_(module_{"example"}, container_{"a"})}});}
+
+                input = "ls /example:a";
+                expected.m_path = path_{Scope::Absolute, {node_(module_{"example"}, container_{"a"})}};
+            }
+
+            SECTION("ls /")
+            {
+                SECTION("cwd: /") {}
+                SECTION("cwd: /example:a") {parser.changeNode(path_{Scope::Relative, {node_(module_{"example"}, container_{"a"})}});}
+                input = "ls /";
+                expected.m_path = path_{Scope::Absolute, {}};
+            }
+
+            SECTION("ls example:a/a2")
+            {
+                input = "ls example:a/a2";
+                expected.m_path = path_{Scope::Relative, {node_(module_{"example"}, container_{"a"}),
+                                                          node_(container_{"a2"})}};
+            }
+
+            SECTION("ls a2")
+            {
+                parser.changeNode(path_{Scope::Relative, {node_(module_{"example"}, container_{"a"})}});
+                input = "ls a2";
+                expected.m_path = path_{Scope::Relative, {node_(container_{"a2"})}};
+            }
+
+            SECTION("ls /example:a/a2")
+            {
+                SECTION("cwd: /") {}
+                SECTION("cwd: /example:a") {parser.changeNode(path_{Scope::Relative, {node_(module_{"example"}, container_{"a"})}});}
+                input = "ls /example:a/a2";
+                expected.m_path = path_{Scope::Absolute, {node_(module_{"example"}, container_{"a"}),
+                                                          node_(container_{"a2"})}};
+            }
+
+            SECTION("ls example:a/example:a2")
+            {
+                input = "ls example:a/example:a2";
+                expected.m_path = path_{Scope::Relative, {node_(module_{"example"}, container_{"a"}),
+                                                          node_(module_{"example"}, container_{"a2"})}};
+            }
+
+            SECTION("ls example:a2")
+            {
+                parser.changeNode(path_{Scope::Relative, {node_(module_{"example"}, container_{"a"})}});
+                input = "ls example:a2";
+                expected.m_path = path_{Scope::Relative, {node_(module_{"example"}, container_{"a2"})}};
+            }
+
+            SECTION("ls /example:a/example:a2")
+            {
+                SECTION("cwd: /") {}
+                SECTION("cwd: /example:a") {parser.changeNode(path_{Scope::Relative, {node_(module_{"example"}, container_{"a"})}});}
+
+                input = "ls /example:a/example:a2";
+                expected.m_path = path_{Scope::Absolute, {node_(module_{"example"}, container_{"a"}),
+                                                          node_(module_{"example"}, container_{"a2"})}};
+            }
         }
 
         command_ command = parser.parseCommand(input, errorStream);
@@ -53,7 +120,20 @@
     {
         SECTION("invalid path")
         {
-            input = "ls example:nonexistent";
+            SECTION("ls example:nonexistent")
+                input = "ls example:nonexistent";
+
+            SECTION("ls /example:nonexistent")
+                input = "ls /example:nonexistent";
+
+            SECTION("ls /bad:nonexistent")
+                input = "ls /bad:nonexistent";
+
+            SECTION( "ls example:a/nonexistent")
+                input = "ls example:a/nonexistent";
+
+            SECTION( "ls /example:a/nonexistent")
+                input = "ls /example:a/nonexistent";
         }
 
         REQUIRE_THROWS(parser.parseCommand(input, errorStream));