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
=== added file 'include/unity/util/SnapPath.h'
--- include/unity/util/SnapPath.h 1970-01-01 00:00:00 +0000
+++ include/unity/util/SnapPath.h 2017-03-28 18:46:38 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright (C) 2016-2017 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#pragma once
19
20#include <string>
21
22namespace unity
23{
24
25namespace util
26{
27
28 std::string prepend_snap_path(const std::string& path);
29
30} // namespace util
31
32} // namespace unity
033
=== modified file 'src/unity/util/CMakeLists.txt'
--- src/unity/util/CMakeLists.txt 2013-06-06 11:43:49 +0000
+++ src/unity/util/CMakeLists.txt 2017-03-28 18:46:38 +0000
@@ -4,6 +4,7 @@
4 ${CMAKE_CURRENT_SOURCE_DIR}/Daemon.cpp4 ${CMAKE_CURRENT_SOURCE_DIR}/Daemon.cpp
5 ${CMAKE_CURRENT_SOURCE_DIR}/FileIO.cpp5 ${CMAKE_CURRENT_SOURCE_DIR}/FileIO.cpp
6 ${CMAKE_CURRENT_SOURCE_DIR}/IniParser.cpp6 ${CMAKE_CURRENT_SOURCE_DIR}/IniParser.cpp
7 ${CMAKE_CURRENT_SOURCE_DIR}/SnapPath.cpp
7)8)
89
9set(UNITY_API_LIB_SRC ${UNITY_API_LIB_SRC} ${UTIL_SRC} PARENT_SCOPE)10set(UNITY_API_LIB_SRC ${UNITY_API_LIB_SRC} ${UTIL_SRC} PARENT_SCOPE)
1011
=== added file 'src/unity/util/SnapPath.cpp'
--- src/unity/util/SnapPath.cpp 1970-01-01 00:00:00 +0000
+++ src/unity/util/SnapPath.cpp 2017-03-28 18:46:38 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2016-2017 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include "unity/util/SnapPath.h"
19
20namespace unity
21{
22
23namespace util
24{
25
26std::string prepend_snap_path(const std::string& path)
27{
28 const char* env_snap = getenv("SNAP");
29 if (env_snap == nullptr) {
30 return path;
31 }
32 return env_snap + path;
33}
34
35} // namespace util
36
37} // namespace unity
038
=== modified file 'test/gtest/unity/util/CMakeLists.txt'
--- test/gtest/unity/util/CMakeLists.txt 2017-01-19 13:52:32 +0000
+++ test/gtest/unity/util/CMakeLists.txt 2017-03-28 18:46:38 +0000
@@ -5,4 +5,5 @@
5add_subdirectory(GObjectMemory)5add_subdirectory(GObjectMemory)
6add_subdirectory(IniParser)6add_subdirectory(IniParser)
7add_subdirectory(ResourcePtr)7add_subdirectory(ResourcePtr)
8add_subdirectory(SnapPath)
8add_subdirectory(internal)9add_subdirectory(internal)
910
=== added directory 'test/gtest/unity/util/SnapPath'
=== added file 'test/gtest/unity/util/SnapPath/CMakeLists.txt'
--- test/gtest/unity/util/SnapPath/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ test/gtest/unity/util/SnapPath/CMakeLists.txt 2017-03-28 18:46:38 +0000
@@ -0,0 +1,4 @@
1add_executable(SnapPath_test SnapPath_test.cpp)
2target_link_libraries(SnapPath_test ${LIBS} ${TESTLIBS})
3
4add_test(SnapPath SnapPath_test)
05
=== added file 'test/gtest/unity/util/SnapPath/SnapPath_test.cpp'
--- test/gtest/unity/util/SnapPath/SnapPath_test.cpp 1970-01-01 00:00:00 +0000
+++ test/gtest/unity/util/SnapPath/SnapPath_test.cpp 2017-03-28 18:46:38 +0000
@@ -0,0 +1,37 @@
1/*
2 * Copyright (C) 2016-2017 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include "unity/util/SnapPath.h"
19
20#include <gtest/gtest.h>
21
22using namespace unity::util;
23
24namespace {
25
26TEST(Utilities, testPrependSnapPathSet) {
27 ASSERT_EQ(0, setenv("SNAP", "/snap", 1));
28 EXPECT_EQ("/snap/bar", prepend_snap_path("/bar"));
29 ASSERT_EQ(0, unsetenv("SNAP"));
30}
31
32TEST(Utilities, testPrependSnapPathUnset) {
33 ASSERT_EQ(0, unsetenv("SNAP"));
34 EXPECT_EQ("/bar", prepend_snap_path("/bar"));
35}
36
37} // namespace

Subscribers

People subscribed via source and target branches

to all changes: