File: 0002-Add-usr-as-default-workspace-path.patch

package info (click to toggle)
ros-catkin 0.8.9-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,088 kB
  • sloc: python: 4,102; sh: 456; xml: 235; makefile: 125; cpp: 121
file content (55 lines) | stat: -rw-r--r-- 2,529 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
From: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date: Fri, 12 Dec 2014 09:31:17 +0100
Subject: Add /usr as default workspace path

---
 python/catkin/workspace.py        |  3 +++
 test/unit_tests/test_workspace.py | 10 +++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/python/catkin/workspace.py b/python/catkin/workspace.py
index 3bf0c41..7cd7293 100644
--- a/python/catkin/workspace.py
+++ b/python/catkin/workspace.py
@@ -48,6 +48,7 @@ def get_workspaces():
     paths = [path for path in os.environ.get(env_name, '').split(os.pathsep) if path]
     # remove non-workspace paths
     workspaces = [path for path in paths if os.path.isfile(os.path.join(path, CATKIN_MARKER_FILE))]
+    workspaces.append('/usr')
     return workspaces
 
 
@@ -59,6 +60,8 @@ def get_source_paths(workspace):
     """
     # determine source spaces
     filename = os.path.join(workspace, CATKIN_MARKER_FILE)
+    if workspace == '/usr':
+        return []
     if not os.path.isfile(filename):
         raise ValueError('Not a catkin workspace: "%s", missing file %s' % (workspace, filename))
     with open(filename) as f:
diff --git a/test/unit_tests/test_workspace.py b/test/unit_tests/test_workspace.py
index 6799c66..d02bd13 100644
--- a/test/unit_tests/test_workspace.py
+++ b/test/unit_tests/test_workspace.py
@@ -28,15 +28,15 @@ class WorkspaceTest(unittest.TestCase):
             with open(os.path.join(ws2, CATKIN_MARKER_FILE), 'w') as fhand:
                 fhand.write('loc3;loc4')
             catkin.workspace.os.environ = {}
-            self.assertEqual([], get_workspaces())
+            self.assertEqual(['/usr'], get_workspaces())
             catkin.workspace.os.environ = {'CMAKE_PREFIX_PATH': ''}
-            self.assertEqual([], get_workspaces())
+            self.assertEqual(['/usr'], get_workspaces())
             catkin.workspace.os.environ = {'CMAKE_PREFIX_PATH': ws1}
-            self.assertEqual([ws1], get_workspaces())
+            self.assertEqual([ws1, '/usr'], get_workspaces())
             catkin.workspace.os.environ = {'CMAKE_PREFIX_PATH': 'nowhere'}
-            self.assertEqual([], get_workspaces())
+            self.assertEqual(['/usr'], get_workspaces())
             catkin.workspace.os.environ = {'CMAKE_PREFIX_PATH': ws2 + os.pathsep + ws1}
-            self.assertEqual([ws2, ws1], get_workspaces())
+            self.assertEqual([ws2, ws1, '/usr'], get_workspaces())
         finally:
             shutil.rmtree(root_dir)
             os.environ = old_environ