Merge lp:~dobey/unity-api/add-snap-util into lp:unity-api

Proposed by dobey
Status: Merged
Approved by: Pete Woods
Approved revision: 277
Merged at revision: 283
Proposed branch: lp:~dobey/unity-api/add-snap-util
Merge into: lp:unity-api
Diff against target: 152 lines (+112/-0)
6 files modified
include/unity/util/SnapPath.h (+32/-0)
src/unity/util/CMakeLists.txt (+1/-0)
src/unity/util/SnapPath.cpp (+37/-0)
test/gtest/unity/util/CMakeLists.txt (+1/-0)
test/gtest/unity/util/SnapPath/CMakeLists.txt (+4/-0)
test/gtest/unity/util/SnapPath/SnapPath_test.cpp (+37/-0)
To merge this branch: bzr merge lp:~dobey/unity-api/add-snap-util
Reviewer Review Type Date Requested Status
Pete Woods (community) Approve
Unity8 CI Bot continuous-integration Approve
Review via email: mp+320529@code.launchpad.net

Commit message

Add utility function to prepend $SNAP to directory paths.

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:276
https://unity8-jenkins.ubuntu.com/job/lp-unity-api-ci/158/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4600
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4628
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4455
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4455/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4455
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4455/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4455
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4455/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4455
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4455/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4455
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4455/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4455
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4455/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity-api-ci/158/rebuild

review: Approve (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) :
Revision history for this message
Pete Woods (pete-woods) :
Revision history for this message
Pete Woods (pete-woods) wrote :

I'd prefer you fix these things

review: Needs Fixing
lp:~dobey/unity-api/add-snap-util updated
277. By dobey

Fixes per review.

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote :

PASSED: Continuous integration, rev:277
https://unity8-jenkins.ubuntu.com/job/lp-unity-api-ci/166/
Executed test runs:
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build/4750
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/4778
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4601
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial+overlay/4601/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4601
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=zesty/4601/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4601
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial+overlay/4601/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4601
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=zesty/4601/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4601
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial+overlay/4601/artifact/output/*zip*/output.zip
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4601
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=zesty/4601/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity-api-ci/166/rebuild

review: Approve (continuous-integration)
Revision history for this message
Pete Woods (pete-woods) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'include/unity/util/SnapPath.h'
2--- include/unity/util/SnapPath.h 1970-01-01 00:00:00 +0000
3+++ include/unity/util/SnapPath.h 2017-03-28 18:46:38 +0000
4@@ -0,0 +1,32 @@
5+/*
6+ * Copyright (C) 2016-2017 Canonical Ltd
7+ *
8+ * This program is free software: you can redistribute it and/or modify
9+ * it under the terms of the GNU Lesser General Public License version 3 as
10+ * published by the Free Software Foundation.
11+ *
12+ * This program is distributed in the hope that it will be useful,
13+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+ * GNU Lesser General Public License for more details.
16+ *
17+ * You should have received a copy of the GNU Lesser General Public License
18+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
19+ *
20+ */
21+
22+#pragma once
23+
24+#include <string>
25+
26+namespace unity
27+{
28+
29+namespace util
30+{
31+
32+ std::string prepend_snap_path(const std::string& path);
33+
34+} // namespace util
35+
36+} // namespace unity
37
38=== modified file 'src/unity/util/CMakeLists.txt'
39--- src/unity/util/CMakeLists.txt 2013-06-06 11:43:49 +0000
40+++ src/unity/util/CMakeLists.txt 2017-03-28 18:46:38 +0000
41@@ -4,6 +4,7 @@
42 ${CMAKE_CURRENT_SOURCE_DIR}/Daemon.cpp
43 ${CMAKE_CURRENT_SOURCE_DIR}/FileIO.cpp
44 ${CMAKE_CURRENT_SOURCE_DIR}/IniParser.cpp
45+ ${CMAKE_CURRENT_SOURCE_DIR}/SnapPath.cpp
46 )
47
48 set(UNITY_API_LIB_SRC ${UNITY_API_LIB_SRC} ${UTIL_SRC} PARENT_SCOPE)
49
50=== added file 'src/unity/util/SnapPath.cpp'
51--- src/unity/util/SnapPath.cpp 1970-01-01 00:00:00 +0000
52+++ src/unity/util/SnapPath.cpp 2017-03-28 18:46:38 +0000
53@@ -0,0 +1,37 @@
54+/*
55+ * Copyright (C) 2016-2017 Canonical Ltd
56+ *
57+ * This program is free software: you can redistribute it and/or modify
58+ * it under the terms of the GNU Lesser General Public License version 3 as
59+ * published by the Free Software Foundation.
60+ *
61+ * This program is distributed in the hope that it will be useful,
62+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
63+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
64+ * GNU Lesser General Public License for more details.
65+ *
66+ * You should have received a copy of the GNU Lesser General Public License
67+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
68+ *
69+ */
70+
71+#include "unity/util/SnapPath.h"
72+
73+namespace unity
74+{
75+
76+namespace util
77+{
78+
79+std::string prepend_snap_path(const std::string& path)
80+{
81+ const char* env_snap = getenv("SNAP");
82+ if (env_snap == nullptr) {
83+ return path;
84+ }
85+ return env_snap + path;
86+}
87+
88+} // namespace util
89+
90+} // namespace unity
91
92=== modified file 'test/gtest/unity/util/CMakeLists.txt'
93--- test/gtest/unity/util/CMakeLists.txt 2017-01-19 13:52:32 +0000
94+++ test/gtest/unity/util/CMakeLists.txt 2017-03-28 18:46:38 +0000
95@@ -5,4 +5,5 @@
96 add_subdirectory(GObjectMemory)
97 add_subdirectory(IniParser)
98 add_subdirectory(ResourcePtr)
99+add_subdirectory(SnapPath)
100 add_subdirectory(internal)
101
102=== added directory 'test/gtest/unity/util/SnapPath'
103=== added file 'test/gtest/unity/util/SnapPath/CMakeLists.txt'
104--- test/gtest/unity/util/SnapPath/CMakeLists.txt 1970-01-01 00:00:00 +0000
105+++ test/gtest/unity/util/SnapPath/CMakeLists.txt 2017-03-28 18:46:38 +0000
106@@ -0,0 +1,4 @@
107+add_executable(SnapPath_test SnapPath_test.cpp)
108+target_link_libraries(SnapPath_test ${LIBS} ${TESTLIBS})
109+
110+add_test(SnapPath SnapPath_test)
111
112=== added file 'test/gtest/unity/util/SnapPath/SnapPath_test.cpp'
113--- test/gtest/unity/util/SnapPath/SnapPath_test.cpp 1970-01-01 00:00:00 +0000
114+++ test/gtest/unity/util/SnapPath/SnapPath_test.cpp 2017-03-28 18:46:38 +0000
115@@ -0,0 +1,37 @@
116+/*
117+ * Copyright (C) 2016-2017 Canonical Ltd
118+ *
119+ * This program is free software: you can redistribute it and/or modify
120+ * it under the terms of the GNU Lesser General Public License version 3 as
121+ * published by the Free Software Foundation.
122+ *
123+ * This program is distributed in the hope that it will be useful,
124+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
125+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
126+ * GNU Lesser General Public License for more details.
127+ *
128+ * You should have received a copy of the GNU Lesser General Public License
129+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
130+ *
131+ */
132+
133+#include "unity/util/SnapPath.h"
134+
135+#include <gtest/gtest.h>
136+
137+using namespace unity::util;
138+
139+namespace {
140+
141+TEST(Utilities, testPrependSnapPathSet) {
142+ ASSERT_EQ(0, setenv("SNAP", "/snap", 1));
143+ EXPECT_EQ("/snap/bar", prepend_snap_path("/bar"));
144+ ASSERT_EQ(0, unsetenv("SNAP"));
145+}
146+
147+TEST(Utilities, testPrependSnapPathUnset) {
148+ ASSERT_EQ(0, unsetenv("SNAP"));
149+ EXPECT_EQ("/bar", prepend_snap_path("/bar"));
150+}
151+
152+} // namespace

Subscribers

People subscribed via source and target branches

to all changes: