[rospack] 01/05: Imported Upstream version 2.2.5
Jochen Sprickerhof
jspricke-guest at moszumanska.debian.org
Fri Dec 12 17:22:44 UTC 2014
This is an automated email from the git hooks/post-receive script.
jspricke-guest pushed a commit to branch master
in repository rospack.
commit 2c0db1857c9071919820045617ff98218363b963
Author: Jochen Sprickerhof <git at jochen.sprickerhof.de>
Date: Fri Dec 12 17:10:21 2014 +0100
Imported Upstream version 2.2.5
---
CHANGELOG.rst | 28 +++-
CMakeLists.txt | 18 +--
include/rospack/rospack.h | 17 ++-
include/rospack/rospack_backcompat.h | 2 +-
package.xml | 4 +-
src/rospack.cpp | 215 +++++++++++++++----------------
src/rospack_backcompat.cpp | 10 +-
src/rospack_cmdline.cpp | 64 +++++-----
src/rospack_cmdline.h | 4 +-
src/rospack_main.cpp | 2 +-
src/rosstack_main.cpp | 2 +-
src/utils.cpp | 10 +-
src/utils.h | 2 +-
test/CMakeLists.txt | 2 +-
test/test/utest.cpp | 19 ++-
test/test/utest.py.in | 240 +++++++++++++++--------------------
16 files changed, 307 insertions(+), 332 deletions(-)
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 57d51af..709e5b2 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -2,18 +2,32 @@
Changelog for package rospack
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-2.1.25 (2014-10-14)
--------------------
+2.2.5 (2014-09-04)
+------------------
+* support tags defined in package format 2 (`#43 <https://github.com/ros/rospack/issues/43>`_)
+
+2.2.4 (2014-07-10)
+------------------
* fix find_package(PythonLibs ...) with CMake 3 (`#42 <https://github.com/ros/rospack/issues/42>`_)
-2.1.24 (2014-09-04)
--------------------
-* support tags defined in package format 2 (`#43 <https://github.com/ros/rospack/issues/43>`_)
+2.2.3 (2014-05-07)
+------------------
+* find library for exact Python version (even if not in CMake provided list of version numbers) (`#40 <https://github.com/ros/rospack/issues/40>`_)
+* find TinyXML using cmake_modules (`#24 <https://github.com/ros/rospack/issues/24>`_)
+* make error messages tool specific (rospack vs. rosstack) (`#38 <https://github.com/ros/rospack/issues/38>`_)
-2.1.23 (2014-02-25)
--------------------
+2.2.2 (2014-02-25)
+------------------
+* python 3 compatibility (`#35 <https://github.com/ros/rospack/issues/35>`_)
+
+2.2.1 (2014-02-24)
+------------------
* only perform backquote substitution when needed (`#34 <https://github.com/ros/rospack/issues/34>`_)
+2.2.0 (2014-01-30)
+------------------
+* add hash of ROS_PACKAGE_PATH to rospack/rosstack cache filename, remove ROS_ROOT from cache (`#28 <https://github.com/ros/rospack/issues/28>`_)
+
2.1.22 (2014-01-07)
-------------------
* use specific python version catkin has decided on (`#29 <https://github.com/ros/rospack/issues/29>`_)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 85d9e3f..6b5bb44 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,22 +1,16 @@
cmake_minimum_required(VERSION 2.8.3)
project(rospack)
-find_package(catkin REQUIRED)
+find_package(catkin REQUIRED COMPONENTS cmake_modules)
find_package(Boost REQUIRED COMPONENTS filesystem program_options system)
set(Python_ADDITIONAL_VERSIONS "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
find_package(PythonLibs "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" REQUIRED)
-find_package(tinyxml QUIET)
-if(NOT tinyxml_FOUND)
- # Just assume it's located in the system directories
- # though you could try and detect stuff via the pkgconfig file
- # it provides
- set(tinyxml_LIBRARIES tinyxml)
-endif()
+find_package(TinyXML REQUIRED)
catkin_package(
INCLUDE_DIRS include
- LIBRARIES rospack tinyxml ${PYTHON_LIBRARIES}
- DEPENDS Boost
+ LIBRARIES rospack ${PYTHON_LIBRARIES}
+ DEPENDS Boost TinyXML
)
#add_definitions(-Wall)
@@ -27,7 +21,7 @@ if(API_BACKCOMPAT_V1)
set(backcompat_source src/rospack_backcompat.cpp)
endif()
-include_directories(include ${tinyxml_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
+include_directories(include ${TinyXML_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS})
add_library(rospack
src/rospack.cpp
@@ -35,7 +29,7 @@ add_library(rospack
src/rospack_cmdline.cpp
src/utils.cpp
)
-target_link_libraries(rospack ${tinyxml_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
+target_link_libraries(rospack ${TinyXML_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})
add_executable(rospackexe src/rospack_main.cpp)
# Set the name, and make it a "global" executable
diff --git a/include/rospack/rospack.h b/include/rospack/rospack.h
index ee13a1e..75a8546 100644
--- a/include/rospack/rospack.h
+++ b/include/rospack/rospack.h
@@ -142,7 +142,7 @@ class ROSPACK_DECL Rosstackage
{
private:
std::string manifest_name_;
- std::string cache_name_;
+ std::string cache_prefix_;
bool crawled_;
std::string name_;
std::string tag_;
@@ -180,6 +180,7 @@ class ROSPACK_DECL Rosstackage
std::vector<std::string>& indented_deps,
bool no_recursion_on_wet=false);
std::string getCachePath();
+ std::string getCacheHash();
bool readCache();
void writeCache();
FILE* validateCache();
@@ -196,13 +197,13 @@ class ROSPACK_DECL Rosstackage
/**
* @brief Constructor, only used by derived classes.
* @param manifest_name What the manifest is called (e.g., "manifest.xml or stack.xml")
- * @param cache_name What the cache is called (e.g., "rospack_cache" or "rosstack_cache")
+ * @param cache_prefix What the cache is called (e.g., "rospack_cache" or "rosstack_cache") excluding the appended search path hash
* @param name Name of the tool we're building (e.g., "rospack" or "rosstack")
* @param tag Name of the attribute we look for in a "depend" tag in a
* manifest (e.g., "package" or "stack")
*/
Rosstackage(const std::string& manifest_name,
- const std::string& cache_name,
+ const std::string& cache_prefix,
const std::string& name,
const std::string& tag);
@@ -527,6 +528,12 @@ re-run the profile with --zombie-only
*/
void logError(const std::string& msg,
bool append_errno = false);
+
+ /*
+ * @brief The manifest type.
+ * @return Either "package" or "stack".
+ */
+ virtual std::string get_manifest_type() { return ""; }
};
/**
@@ -545,6 +552,8 @@ class ROSPACK_DECL Rospack : public Rosstackage
* @return Command-line usage for the rospack tool.
*/
virtual const char* usage();
+
+ virtual std::string get_manifest_type();
};
/**
@@ -563,6 +572,8 @@ class ROSPACK_DECL Rosstack : public Rosstackage
* @return Command-line usage for the rosstack tool.
*/
virtual const char* usage();
+
+ virtual std::string get_manifest_type();
};
} // namespace rospack
diff --git a/include/rospack/rospack_backcompat.h b/include/rospack/rospack_backcompat.h
index 9af57f0..bd60ec0 100644
--- a/include/rospack/rospack_backcompat.h
+++ b/include/rospack/rospack_backcompat.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008, Willow Garage, Inc.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
diff --git a/package.xml b/package.xml
index f0dfc3f..2a8bc51 100644
--- a/package.xml
+++ b/package.xml
@@ -1,6 +1,6 @@
<package>
<name>rospack</name>
- <version>2.1.25</version>
+ <version>2.2.5</version>
<description>ROS Package Tool</description>
<maintainer email="dthomas at osrfoundation.org">Dirk Thomas</maintainer>
<license>BSD</license>
@@ -16,13 +16,13 @@
<buildtool_depend version_gte="0.5.68">catkin</buildtool_depend>
<build_depend>boost</build_depend>
+ <build_depend>cmake_modules</build_depend>
<build_depend>gtest</build_depend>
<build_depend>pkg-config</build_depend>
<build_depend>python</build_depend>
<build_depend>tinyxml</build_depend>
<run_depend>boost</run_depend>
- <run_depend>gtest</run_depend>
<run_depend>pkg-config</run_depend>
<run_depend>python</run_depend>
<run_depend>python-catkin-pkg</run_depend>
diff --git a/src/rospack.cpp b/src/rospack.cpp
index 54f7f2a..efe6c11 100644
--- a/src/rospack.cpp
+++ b/src/rospack.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008, Willow Garage, Inc., Morgan Quigley
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
@@ -29,8 +29,9 @@
#include "utils.h"
#include "tinyxml.h"
-#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/functional/hash.hpp>
#include <stdexcept>
#if defined(WIN32)
@@ -70,10 +71,11 @@
#include <Python.h>
-/* re-define some String functions for recent python (>= 3.0) */
-#if PY_VERSION_HEX >= 0x03000000
-#define PyString_AsString PyBytes_AsString
-#define PyString_FromString PyBytes_FromString
+/* re-define some String functions for python 2.x */
+#if PY_VERSION_HEX < 0x03000000
+#define PyBytes_AsString PyString_AsString
+#define PyUnicode_AsUTF8 PyString_AsString
+#define PyUnicode_FromString PyString_FromString
#endif
// TODO:
@@ -90,8 +92,8 @@ static const char* MANIFEST_TAG_STACK = "stack";
static const char* ROSPACK_MANIFEST_NAME = "manifest.xml";
static const char* ROSPACKAGE_MANIFEST_NAME = "package.xml";
static const char* ROSSTACK_MANIFEST_NAME = "stack.xml";
-static const char* ROSPACK_CACHE_NAME = "rospack_cache";
-static const char* ROSSTACK_CACHE_NAME = "rosstack_cache";
+static const char* ROSPACK_CACHE_PREFIX = "rospack_cache";
+static const char* ROSSTACK_CACHE_PREFIX = "rosstack_cache";
static const char* ROSPACK_NOSUBDIRS = "rospack_nosubdirs";
static const char* CATKIN_IGNORE = "CATKIN_IGNORE";
static const char* DOTROS_NAME = ".ros";
@@ -208,8 +210,8 @@ class DirectoryCrawlRecord
double start_time_;
double crawl_time_;
size_t start_num_pkgs_;
- DirectoryCrawlRecord(std::string path,
- double start_time,
+ DirectoryCrawlRecord(std::string path,
+ double start_time,
size_t start_num_pkgs) :
path_(path),
zombie_(false),
@@ -227,18 +229,18 @@ bool cmpDirectoryCrawlRecord(DirectoryCrawlRecord* i,
// Rosstackage methods (public/protected)
/////////////////////////////////////////////////////////////
Rosstackage::Rosstackage(const std::string& manifest_name,
- const std::string& cache_name,
+ const std::string& cache_prefix,
const std::string& name,
const std::string& tag) :
manifest_name_(manifest_name),
- cache_name_(cache_name),
+ cache_prefix_(cache_prefix),
crawled_(false),
name_(name),
tag_(tag)
{
}
-void
+void
Rosstackage::logWarn(const std::string& msg,
bool append_errno)
{
@@ -254,24 +256,7 @@ Rosstackage::logError(const std::string& msg,
bool
Rosstackage::getSearchPathFromEnv(std::vector<std::string>& sp)
{
- char* rr = getenv("ROS_ROOT");
char* rpp = getenv("ROS_PACKAGE_PATH");
-
- // ROS_ROOT is optional, and will be phased out
- if(rr)
- {
- try
- {
- if(fs::is_directory(rr))
- sp.push_back(rr);
- else
- logWarn(std::string("ROS_ROOT=") + rr + " is not a directory");
- }
- catch(fs::filesystem_error& e)
- {
- logWarn(std::string("error while looking at ROS_ROOT ") + rr + ": " + e.what());
- }
- }
if(rpp)
{
// I can't see that boost filesystem has an elegant cross platform
@@ -283,7 +268,7 @@ Rosstackage::getSearchPathFromEnv(std::vector<std::string>& sp)
#endif
std::vector<std::string> rpp_strings;
- boost::split(rpp_strings, rpp,
+ boost::split(rpp_strings, rpp,
boost::is_any_of(path_delim),
boost::token_compress_on);
for(std::vector<std::string>::const_iterator it = rpp_strings.begin();
@@ -401,13 +386,13 @@ Rosstackage::crawl(std::vector<std::string> search_path,
p != search_paths_.end();
++p)
crawlDetail(*p, force, 1, false, dummy, dummy2);
-
+
crawled_ = true;
writeCache();
}
-bool
+bool
Rosstackage::inStackage(std::string& name)
{
fs::path path;
@@ -457,7 +442,7 @@ Rosstackage::find(const std::string& name, std::string& path)
}
bool
-Rosstackage::contents(const std::string& name,
+Rosstackage::contents(const std::string& name,
std::set<std::string>& packages)
{
Rospack rp2;
@@ -483,7 +468,7 @@ Rosstackage::contents(const std::string& name,
}
bool
-Rosstackage::contains(const std::string& name,
+Rosstackage::contains(const std::string& name,
std::string& stack,
std::string& path)
{
@@ -514,21 +499,21 @@ Rosstackage::contains(const std::string& name,
return false;
}
-void
+void
Rosstackage::list(std::set<std::pair<std::string, std::string> >& list)
{
for(std::tr1::unordered_map<std::string, Stackage*>::const_iterator it = stackages_.begin();
it != stackages_.end();
++it)
{
- std::pair<std::string, std::string> item;
- item.first = it->first;
- item.second = it->second->path_;
- list.insert(item);
+ std::pair<std::string, std::string> item;
+ item.first = it->first;
+ item.second = it->second->path_;
+ list.insert(item);
}
}
-void
+void
Rosstackage::listDuplicates(std::vector<std::string>& dups)
{
dups.resize(dups_.size());
@@ -650,7 +635,7 @@ Rosstackage::depsWhy(const std::string& from,
logError(e.what());
return true;
}
- output.append(std::string("Dependency chains from ") +
+ output.append(std::string("Dependency chains from ") +
from + " to " + to + ":\n");
for(std::list<std::list<Stackage*> >::const_iterator it = acc_list.begin();
it != acc_list.end();
@@ -671,7 +656,7 @@ Rosstackage::depsWhy(const std::string& from,
}
bool
-Rosstackage::depsManifests(const std::string& name, bool direct,
+Rosstackage::depsManifests(const std::string& name, bool direct,
std::vector<std::string>& manifests)
{
Stackage* stackage = findWithRecrawl(name);
@@ -696,7 +681,7 @@ Rosstackage::depsManifests(const std::string& name, bool direct,
}
bool
-Rosstackage::rosdeps(const std::string& name, bool direct,
+Rosstackage::rosdeps(const std::string& name, bool direct,
std::set<std::string>& rosdeps)
{
Stackage* stackage = findWithRecrawl(name);
@@ -770,7 +755,7 @@ Rosstackage::_rosdeps(Stackage* stackage, std::set<std::string>& rosdeps, const
}
bool
-Rosstackage::vcs(const std::string& name, bool direct,
+Rosstackage::vcs(const std::string& name, bool direct,
std::vector<std::string>& vcs)
{
Stackage* stackage = findWithRecrawl(name);
@@ -817,7 +802,7 @@ Rosstackage::vcs(const std::string& name, bool direct,
return true;
}
-bool
+bool
Rosstackage::cpp_exports(const std::string& name, const std::string& type,
const std::string& attrib, bool deps_only,
std::vector<std::pair<std::string, bool> >& flags)
@@ -863,7 +848,7 @@ Rosstackage::cpp_exports(const std::string& name, const std::string& type,
if(!init_py)
{
init_py = true;
- pName = PyString_FromString("rosdep2.rospack");
+ pName = PyUnicode_FromString("rosdep2.rospack");
pModule = PyImport_Import(pName);
if(!pModule)
{
@@ -885,9 +870,9 @@ Rosstackage::cpp_exports(const std::string& name, const std::string& type,
}
PyObject* pArgs = PyTuple_New(2);
- PyObject* pOpt = PyString_FromString(type.c_str());
+ PyObject* pOpt = PyUnicode_FromString(type.c_str());
PyTuple_SetItem(pArgs, 0, pOpt);
- PyObject* pPkg = PyString_FromString((*it)->name_.c_str());
+ PyObject* pPkg = PyUnicode_FromString((*it)->name_.c_str());
PyTuple_SetItem(pArgs, 1, pPkg);
PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
Py_DECREF(pArgs);
@@ -906,7 +891,7 @@ Rosstackage::cpp_exports(const std::string& name, const std::string& type,
throw Exception(errmsg);
}
- flags.push_back(std::pair<std::string, bool>(PyString_AsString(pValue), true));
+ flags.push_back(std::pair<std::string, bool>(PyBytes_AsString(pValue), true));
Py_DECREF(pValue);
// we want to keep the static objects alive for repeated access
@@ -942,7 +927,7 @@ Rosstackage::reorder_paths(const std::string& paths, std::string& reordered)
if(!init_py)
{
init_py = true;
- pName = PyString_FromString("catkin_pkg.rospack");
+ pName = PyUnicode_FromString("catkin_pkg.rospack");
pModule = PyImport_Import(pName);
if(!pModule)
{
@@ -965,7 +950,7 @@ Rosstackage::reorder_paths(const std::string& paths, std::string& reordered)
PyObject* pArgs = PyTuple_New(1);
- PyTuple_SetItem(pArgs, 0, PyString_FromString(paths.c_str()));
+ PyTuple_SetItem(pArgs, 0, PyUnicode_FromString(paths.c_str()));
PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
Py_DECREF(pArgs);
@@ -977,7 +962,7 @@ Rosstackage::reorder_paths(const std::string& paths, std::string& reordered)
throw Exception(errmsg);
}
- reordered = PyString_AsString(pValue);
+ reordered = PyUnicode_AsUTF8(pValue);
Py_DECREF(pValue);
// we want to keep the static objects alive for repeated access
@@ -992,7 +977,7 @@ Rosstackage::reorder_paths(const std::string& paths, std::string& reordered)
return true;
}
-bool
+bool
Rosstackage::exports(const std::string& name, const std::string& lang,
const std::string& attrib, bool deps_only,
std::vector<std::string>& flags)
@@ -1025,7 +1010,7 @@ Rosstackage::exports(const std::string& name, const std::string& lang,
return true;
}
-bool
+bool
Rosstackage::exports_dry_package(Stackage* stackage, const std::string& lang,
const std::string& attrib,
std::vector<std::string>& flags)
@@ -1093,8 +1078,8 @@ Rosstackage::exports_dry_package(Stackage* stackage, const std::string& lang,
return true;
}
-bool
-Rosstackage::plugins(const std::string& name, const std::string& attrib,
+bool
+Rosstackage::plugins(const std::string& name, const std::string& attrib,
const std::string& top,
std::vector<std::string>& flags)
{
@@ -1160,7 +1145,7 @@ Rosstackage::plugins(const std::string& name, const std::string& attrib,
}
bool
-Rosstackage::depsMsgSrv(const std::string& name, bool direct,
+Rosstackage::depsMsgSrv(const std::string& name, bool direct,
std::vector<std::string>& gens)
{
Stackage* stackage = findWithRecrawl(name);
@@ -1175,11 +1160,11 @@ Rosstackage::depsMsgSrv(const std::string& name, bool direct,
it != deps_vec.end();
++it)
{
- fs::path msg_gen = fs::path((*it)->path_) /
- MSG_GEN_GENERATED_DIR /
+ fs::path msg_gen = fs::path((*it)->path_) /
+ MSG_GEN_GENERATED_DIR /
MSG_GEN_GENERATED_FILE;
- fs::path srv_gen = fs::path((*it)->path_) /
- SRV_GEN_GENERATED_DIR /
+ fs::path srv_gen = fs::path((*it)->path_) /
+ SRV_GEN_GENERATED_DIR /
SRV_GEN_GENERATED_FILE;
if(fs::is_regular_file(msg_gen))
gens.push_back(msg_gen.string());
@@ -1199,7 +1184,7 @@ Rosstackage::depsMsgSrv(const std::string& name, bool direct,
// Rosstackage methods (private)
/////////////////////////////////////////////////////////////
-void
+void
Rosstackage::log(const std::string& level,
const std::string& msg,
bool append_errno)
@@ -1227,7 +1212,7 @@ Rosstackage::findWithRecrawl(const std::string& name)
return stackages_[name];
}
- logError(std::string("stack/package ") + name + " not found");
+ logError(get_manifest_type() + " '" + name + "' not found");
return NULL;
}
@@ -1378,7 +1363,7 @@ Rosstackage::profile(const std::vector<std::string>& search_path,
char buf[16];
snprintf(buf, sizeof(buf), "%.6f", (*it)->crawl_time_);
if(length < 0 || i < length)
- dirs.push_back(std::string(buf) + " " +
+ dirs.push_back(std::string(buf) + " " +
((*it)->zombie_ ? "* " : " ") +
(*it)->path_);
i++;
@@ -1549,7 +1534,7 @@ Rosstackage::crawlDetail(const std::string& path,
{
// Measure the elapsed time
dcr->crawl_time_ = time_since_epoch() - dcr->start_time_;
- // If the number of packages didn't change while crawling,
+ // If the number of packages didn't change while crawling,
// then this directory is a zombie
if(stackages_.size() == dcr->start_num_pkgs_)
dcr->zombie_ = true;
@@ -1564,7 +1549,7 @@ Rosstackage::loadManifest(Stackage* stackage)
if(!stackage->manifest_.LoadFile(stackage->manifest_path_))
{
- std::string errmsg = std::string("error parsing manifest of package ") +
+ std::string errmsg = std::string("error parsing manifest of package ") +
stackage->name_ + " at " + stackage->manifest_path_;
throw Exception(errmsg);
}
@@ -1636,7 +1621,7 @@ Rosstackage::computeDepsInternal(Stackage* stackage, bool ignore_errors, const s
{
if(!ignore_errors)
{
- std::string errmsg = std::string("package/stack ") + stackage->name_ + " depends on itself";
+ std::string errmsg = get_manifest_type() + " '" + stackage->name_ + "' depends on itself";
throw Exception(errmsg);
}
}
@@ -1653,7 +1638,7 @@ Rosstackage::computeDepsInternal(Stackage* stackage, bool ignore_errors, const s
}
else
{
- std::string errmsg = std::string("package/stack '") + stackage->name_ + "' depends on non-existent package '" + dep_pkgname + "' and rosdep claims that it is not a system dependency. Check the ROS_PACKAGE_PATH or try calling 'rosdep update'";
+ std::string errmsg = get_manifest_type() + " '" + stackage->name_ + "' depends on non-existent package '" + dep_pkgname + "' and rosdep claims that it is not a system dependency. Check the ROS_PACKAGE_PATH or try calling 'rosdep update'";
throw Exception(errmsg);
}
}
@@ -1689,14 +1674,14 @@ Rosstackage::isSysPackage(const std::string& pkgname)
return cache.find(pkgname)->second;
}
- initPython();
+ initPython();
PyGILState_STATE gstate = PyGILState_Ensure();
static PyObject* pModule = 0;
static PyObject* pDict = 0;
if(!pModule)
{
- PyObject* pName = PyString_FromString("rosdep2.rospack");
+ PyObject* pName = PyUnicode_FromString("rosdep2.rospack");
pModule = PyImport_Import(pName);
Py_DECREF(pName);
if(!pModule)
@@ -1766,7 +1751,7 @@ Rosstackage::isSysPackage(const std::string& pkgname)
PyObject* pArgs = PyTuple_New(2);
PyTuple_SetItem(pArgs, 0, pView);
- PyObject* pDep = PyString_FromString(pkgname.c_str());
+ PyObject* pDep = PyUnicode_FromString(pkgname.c_str());
PyTuple_SetItem(pArgs, 1, pDep);
PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
Py_INCREF(pView); // in order to keep the view when garbaging pArgs
@@ -1790,14 +1775,14 @@ Rosstackage::isSysPackage(const std::string& pkgname)
}
void
-Rosstackage::gatherDeps(Stackage* stackage, bool direct,
+Rosstackage::gatherDeps(Stackage* stackage, bool direct,
traversal_order_t order,
std::vector<Stackage*>& deps,
bool no_recursion_on_wet)
{
std::tr1::unordered_set<Stackage*> deps_hash;
std::vector<std::string> indented_deps;
- gatherDepsFull(stackage, direct, order, 0,
+ gatherDepsFull(stackage, direct, order, 0,
deps_hash, deps, false, indented_deps, no_recursion_on_wet);
}
@@ -1920,11 +1905,11 @@ Rosstackage::getCachePath()
{
// Get the user's home directory by looking up the password entry based
// on UID. If that doesn't work, we fall back on examining $HOME,
- // knowing that that can cause trouble when mixed with sudo (#2884).
+ // knowing that that can cause trouble when mixed with sudo (#2884).
#if defined(WIN32)
char* home_drive = getenv("HOMEDRIVE");
char* home_path = getenv("HOMEPATH");
- if(home_drive && home_path)
+ if(home_drive && home_path)
cache_path = fs::path(home_drive) / fs::path(home_path) / fs::path(DOTROS_NAME);
#else // UNIX
char* home_path;
@@ -1952,10 +1937,24 @@ Rosstackage::getCachePath()
logWarn(std::string("cannot create rospack cache directory ") +
cache_path.string() + ": " + e.what());
}
- cache_path /= cache_name_;
+ cache_path /= cache_prefix_ + "_" + getCacheHash();
return cache_path.string();
}
+std::string
+Rosstackage::getCacheHash()
+{
+ size_t value = 0;
+ char* rpp = getenv("ROS_PACKAGE_PATH");
+ if(rpp != NULL) {
+ boost::hash<std::string> hash_func;
+ value = hash_func(rpp);
+ }
+ char buffer[21];
+ snprintf(buffer, 21, "%020lu", value);
+ return buffer;
+}
+
bool
Rosstackage::readCache()
{
@@ -2039,7 +2038,7 @@ Rosstackage::writeCache()
int fd = mkstemp(tmp_cache_path);
if (fd < 0)
{
- fprintf(stderr, "[rospack] Unable to create temporary cache file %s: %s\n",
+ fprintf(stderr, "[rospack] Unable to create temporary cache file %s: %s\n",
tmp_cache_path, strerror(errno));
}
else
@@ -2048,15 +2047,11 @@ Rosstackage::writeCache()
#endif
if (!cache)
{
- fprintf(stderr, "[rospack] Unable open cache file %s: %s\n",
+ fprintf(stderr, "[rospack] Unable open cache file %s: %s\n",
tmp_cache_path, strerror(errno));
}
else
{
- // TODO: remove writing of ROS_ROOT
- char *rr = getenv("ROS_ROOT");
- fprintf(cache, "#ROS_ROOT=%s\n", (rr ? rr : ""));
-
char *rpp = getenv("ROS_PACKAGE_PATH");
fprintf(cache, "#ROS_PACKAGE_PATH=%s\n", (rpp ? rpp : ""));
for(std::tr1::unordered_map<std::string, Stackage*>::const_iterator it = stackages_.begin();
@@ -2068,7 +2063,7 @@ Rosstackage::writeCache()
remove(cache_path.c_str());
if(rename(tmp_cache_path, cache_path.c_str()) < 0)
{
- fprintf(stderr, "[rospack] Error: failed to rename cache file %s to %s: %s\n",
+ fprintf(stderr, "[rospack] Error: failed to rename cache file %s to %s: %s\n",
tmp_cache_path, cache_path.c_str(), strerror(errno));
}
}
@@ -2096,17 +2091,14 @@ Rosstackage::validateCache()
if ((cache_max_age > 0.0) && (dt > cache_max_age))
return NULL;
}
- // try to open it
+ // try to open it
FILE* cache = fopen(cache_path.c_str(), "r");
if(!cache)
return NULL; // it's not readable by us. sad.
// see if ROS_PACKAGE_PATH matches
char linebuf[30000];
- bool ros_root_ok = false;
bool ros_package_path_ok = false;
- // TODO: remove ROS_ROOT
- const char* ros_root = getenv("ROS_ROOT");
const char* ros_package_path = getenv("ROS_PACKAGE_PATH");
for(;;)
{
@@ -2115,17 +2107,7 @@ Rosstackage::validateCache()
linebuf[strlen(linebuf)-1] = 0; // get rid of trailing newline
if (linebuf[0] == '#')
{
- if (!strncmp("#ROS_ROOT=", linebuf, 10))
- {
- if(!ros_root)
- {
- if(!strlen(linebuf+10))
- ros_root_ok = true;
- }
- else if (!strcmp(linebuf+10, ros_root))
- ros_root_ok = true;
- }
- else if(!strncmp("#ROS_PACKAGE_PATH=", linebuf, 18))
+ if(!strncmp("#ROS_PACKAGE_PATH=", linebuf, 18))
{
if(!ros_package_path)
{
@@ -2139,7 +2121,7 @@ Rosstackage::validateCache()
else
break; // we're out of the header. nothing more matters to this check.
}
- if(ros_root_ok && ros_package_path_ok)
+ if(ros_package_path_ok)
{
// seek to the beginning and pass back the stream (instead of closing
// and later reopening, which is a race condition, #1666)
@@ -2163,10 +2145,13 @@ Rosstackage::expandExportString(Stackage* stackage,
i != std::string::npos;
i = outstring.find(MANIFEST_PREFIX))
{
- outstring.replace(i, std::string(MANIFEST_PREFIX).length(),
+ outstring.replace(i, std::string(MANIFEST_PREFIX).length(),
stackage->path_);
}
+ // skip substitution attempt when the string neither contains
+ // a dollar sign for $(command) and $envvar nor
+ // a backtick wrapping a command
if (outstring.find_first_of("$`") == std::string::npos)
{
return true;
@@ -2186,7 +2171,7 @@ Rosstackage::expandExportString(Stackage* stackage,
// Remove embedded newlines
std::string token("\n");
- for (std::string::size_type s = cmd.find(token);
+ for (std::string::size_type s = cmd.find(token);
s != std::string::npos;
s = cmd.find(token, s))
cmd.replace(s,token.length(),std::string(" "));
@@ -2194,7 +2179,7 @@ Rosstackage::expandExportString(Stackage* stackage,
FILE* p;
if(!(p = popen(cmd.c_str(), "r")))
{
- std::string errmsg =
+ std::string errmsg =
std::string("failed to execute backquote expression ") +
cmd + " in " +
stackage->manifest_path_;
@@ -2214,7 +2199,7 @@ Rosstackage::expandExportString(Stackage* stackage,
// Close the subprocess, checking exit status
if(pclose(p) != 0)
{
- std::string errmsg =
+ std::string errmsg =
std::string("got non-zero exit status from executing backquote expression ") +
cmd + " in " +
stackage->manifest_path_;
@@ -2237,7 +2222,7 @@ Rosstackage::expandExportString(Stackage* stackage,
/////////////////////////////////////////////////////////////
Rospack::Rospack() :
Rosstackage(ROSPACK_MANIFEST_NAME,
- ROSPACK_CACHE_NAME,
+ ROSPACK_CACHE_PREFIX,
ROSPACK_NAME,
MANIFEST_TAG_PACKAGE)
{
@@ -2253,7 +2238,7 @@ Rosstackage::~Rosstackage()
}
}
-const char*
+const char*
Rospack::usage()
{
return "USAGE: rospack <command> [options] [package]\n"
@@ -2290,18 +2275,23 @@ Rospack::usage()
" is used (if it contains a manifest.xml).\n\n";
}
+std::string Rospack::get_manifest_type()
+{
+ return "package";
+}
+
/////////////////////////////////////////////////////////////
// Rosstack methods
/////////////////////////////////////////////////////////////
Rosstack::Rosstack() :
Rosstackage(ROSSTACK_MANIFEST_NAME,
- ROSSTACK_CACHE_NAME,
+ ROSSTACK_CACHE_PREFIX,
ROSSTACK_NAME,
MANIFEST_TAG_STACK)
{
}
-const char*
+const char*
Rosstack::usage()
{
return "USAGE: rosstack [options] <command> [stack]\n"
@@ -2325,20 +2315,25 @@ Rosstack::usage()
" is used (if it contains a stack.xml).\n\n";
}
+std::string Rosstack::get_manifest_type()
+{
+ return "stack";
+}
+
TiXmlElement*
get_manifest_root(Stackage* stackage)
{
TiXmlElement* ele = stackage->manifest_.RootElement();
if(!ele)
{
- std::string errmsg = std::string("error parsing manifest of package ") +
+ std::string errmsg = std::string("error parsing manifest of package ") +
stackage->name_ + " at " + stackage->manifest_path_;
throw Exception(errmsg);
}
return ele;
}
-double
+double
time_since_epoch()
{
#if defined(WIN32)
diff --git a/src/rospack_backcompat.cpp b/src/rospack_backcompat.cpp
index 0bccca1..5caf2b4 100644
--- a/src/rospack_backcompat.cpp
+++ b/src/rospack_backcompat.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008, Willow Garage, Inc., Morgan Quigley
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
@@ -37,7 +37,7 @@
namespace rospack
{
-int
+int
ROSPack::run(int argc, char** argv)
{
rospack::Rospack rp;
@@ -51,7 +51,7 @@ ROSPack::run(int argc, char** argv)
return 0;
}
-int
+int
ROSPack::run(const std::string& cmd)
{
// Callers of this method don't make 'rospack' argv[0].
@@ -60,7 +60,7 @@ ROSPack::run(const std::string& cmd)
int argc;
char** argv;
std::vector<std::string> full_cmd_split;
- boost::split(full_cmd_split, full_cmd,
+ boost::split(full_cmd_split, full_cmd,
boost::is_any_of(" "),
boost::token_compress_on);
argc = full_cmd_split.size();
@@ -81,7 +81,7 @@ ROSPack::run(const std::string& cmd)
for(int i=0; i<argc; i++)
delete[] argv[i];
delete[] argv;
-
+
return ret;
}
diff --git a/src/rospack_cmdline.cpp b/src/rospack_cmdline.cpp
index c35c9de..46eade5 100644
--- a/src/rospack_cmdline.cpp
+++ b/src/rospack_cmdline.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008, Willow Garage, Inc.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
@@ -41,7 +41,7 @@ namespace po = boost::program_options;
namespace rospack
{
-bool parse_args(int argc, char** argv,
+bool parse_args(int argc, char** argv,
rospack::Rosstackage& rp,
po::variables_map& vm);
@@ -198,7 +198,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
// COMMAND: profile
if(command == "profile")
{
- if(package_given || target.size() || top.size() ||
+ if(package_given || target.size() || top.size() ||
deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -216,16 +216,16 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
// We crawl here because profile (above) does its own special crawl.
rp.crawl(search_path, force);
-
+
// COMMAND: find [package]
if(command == "find")
{
if(!package.size())
{
- rp.logError( "no package/stack given");
+ rp.logError(std::string("no ") + rp.get_manifest_type() + " given");
return false;
}
- if(target.size() || top.size() || length_str.size() ||
+ if(target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -240,7 +240,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
// COMMAND: list
else if(command == "list")
{
- if(package_given || target.size() || top.size() || length_str.size() ||
+ if(package_given || target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -259,7 +259,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
// COMMAND: list-names
else if(command == "list-names")
{
- if(package_given || target.size() || top.size() || length_str.size() ||
+ if(package_given || target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -278,7 +278,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
// COMMAND: list-duplicates
else if(command == "list-duplicates")
{
- if(package_given || target.size() || top.size() || length_str.size() ||
+ if(package_given || target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -304,7 +304,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
// COMMAND: langs
else if(rp.getName() == ROSPACK_NAME && command == "langs")
{
- if(package_given || target.size() || top.size() || length_str.size() ||
+ if(package_given || target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -330,7 +330,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
std::vector<std::string>::iterator it = deps.begin();
while(it != deps.end())
{
- if(std::find(disable_langs.begin(), disable_langs.end(), *it) !=
+ if(std::find(disable_langs.begin(), disable_langs.end(), *it) !=
disable_langs.end())
it = deps.erase(it);
else
@@ -349,15 +349,15 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
return true;
}
// COMMAND: depends [package] (alias: deps)
- else if(command == "depends" || command == "deps" ||
+ else if(command == "depends" || command == "deps" ||
command == "depends1" || command == "deps1")
{
if(!package.size())
{
- rp.logError( "no package/stack given");
+ rp.logError(std::string("no ") + rp.get_manifest_type() + " given");
return false;
}
- if(target.size() || top.size() || length_str.size() ||
+ if(target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -377,10 +377,10 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
{
if(!package.size())
{
- rp.logError( "no package/stack given");
+ rp.logError(std::string("no ") + rp.get_manifest_type() + " given");
return false;
}
- if(target.size() || top.size() || length_str.size() ||
+ if(target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -401,7 +401,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
return true;
}
// COMMAND: depends-msgsrv [package] (alias: deps-msgsrv)
- else if(rp.getName() == ROSPACK_NAME &&
+ else if(rp.getName() == ROSPACK_NAME &&
(command == "depends-msgsrv" || command == "deps-msgsrv"))
{
if(!package.size())
@@ -409,7 +409,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
rp.logError( "no package given");
return false;
}
- if(target.size() || top.size() || length_str.size() ||
+ if(target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -434,10 +434,10 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
{
if(!package.size())
{
- rp.logError( "no package/stack given");
+ rp.logError(std::string("no ") + rp.get_manifest_type() + " given");
return false;
}
- if(target.size() || top.size() || length_str.size() ||
+ if(target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -457,10 +457,10 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
{
if(!package.size() || !target.size())
{
- rp.logError( "no package/stack or target given");
+ rp.logError(std::string("no ") + rp.get_manifest_type() + " or target given");
return false;
}
- if(top.size() || length_str.size() ||
+ if(top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -474,7 +474,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
}
// COMMAND: rosdep [package] (alias: rosdeps)
// COMMAND: rosdep0 [package] (alias: rosdeps0)
- else if(rp.getName() == ROSPACK_NAME &&
+ else if(rp.getName() == ROSPACK_NAME &&
(command == "rosdep" || command == "rosdeps" ||
command == "rosdep0" || command == "rosdeps0"))
{
@@ -483,7 +483,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
rp.logError( "no package given");
return false;
}
- if(target.size() || top.size() || length_str.size() ||
+ if(target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -500,7 +500,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
}
// COMMAND: vcs [package]
// COMMAND: vcs0 [package]
- else if(rp.getName() == ROSPACK_NAME &&
+ else if(rp.getName() == ROSPACK_NAME &&
(command == "vcs" || command == "vcs0"))
{
if(!package.size())
@@ -508,7 +508,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
rp.logError( "no package given");
return false;
}
- if(target.size() || top.size() || length_str.size() ||
+ if(target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -529,10 +529,10 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
{
if(!package.size())
{
- rp.logError( "no package/stack given");
+ rp.logError(std::string("no ") + rp.get_manifest_type() + " given");
return false;
}
- if(target.size() || top.size() || length_str.size() ||
+ if(target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -780,7 +780,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
rp.logError( "no stack given");
return false;
}
- if(target.size() || top.size() || length_str.size() ||
+ if(target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -796,7 +796,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
return true;
}
// COMMAND: contains [package]
- else if(rp.getName() == ROSSTACK_NAME &&
+ else if(rp.getName() == ROSSTACK_NAME &&
((command == "contains") || (command == "contains-path")))
{
if(!package.size())
@@ -804,7 +804,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
rp.logError( "no package given");
return false;
}
- if(target.size() || top.size() || length_str.size() ||
+ if(target.size() || top.size() || length_str.size() ||
zombie_only || deps_only || lang.size() || attrib.size())
{
rp.logError( "invalid option(s) given");
@@ -827,7 +827,7 @@ rospack_run(int argc, char** argv, rospack::Rosstackage& rp, std::string& output
}
bool
-parse_args(int argc, char** argv,
+parse_args(int argc, char** argv,
rospack::Rosstackage& rp, po::variables_map& vm)
{
po::options_description desc("Allowed options");
diff --git a/src/rospack_cmdline.h b/src/rospack_cmdline.h
index 56e6c77..3b19617 100644
--- a/src/rospack_cmdline.h
+++ b/src/rospack_cmdline.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008, Willow Garage, Inc.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
@@ -35,7 +35,7 @@ namespace rospack
{
ROSPACK_DECL bool rospack_run(int argc, char** argv,
- rospack::Rosstackage& rp,
+ rospack::Rosstackage& rp,
std::string& output);
}
diff --git a/src/rospack_main.cpp b/src/rospack_main.cpp
index d14612c..85fbacf 100644
--- a/src/rospack_main.cpp
+++ b/src/rospack_main.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008, Willow Garage, Inc.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
diff --git a/src/rosstack_main.cpp b/src/rosstack_main.cpp
index df9d086..b3746fc 100644
--- a/src/rosstack_main.cpp
+++ b/src/rosstack_main.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008, Willow Garage, Inc.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
diff --git a/src/utils.cpp b/src/utils.cpp
index af36c8a..97a557a 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008, Willow Garage, Inc.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
@@ -36,7 +36,7 @@ namespace rospack
{
void
-deduplicate_tokens(const std::string& instring,
+deduplicate_tokens(const std::string& instring,
bool last,
std::string& outstring)
{
@@ -72,7 +72,7 @@ deduplicate_tokens(const std::string& instring,
}
void
-parse_compiler_flags(const std::string& instring,
+parse_compiler_flags(const std::string& instring,
const std::string& token,
bool select,
bool last,
@@ -120,8 +120,8 @@ parse_compiler_flags(const std::string& instring,
}
}
// Special case: if we're told to look for -l, then also find *.a
- else if(it->size() > 2 &&
- (*it)[0] == '/' &&
+ else if(it->size() > 2 &&
+ (*it)[0] == '/' &&
it->substr(it->size()-2) == ".a")
{
if(select)
diff --git a/src/utils.h b/src/utils.h
index 02e1de1..485b00c 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008, Willow Garage, Inc.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright notice,
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index e0fe86f..9817ddb 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -9,7 +9,7 @@ endif()
# Prepare to run the tests. This could be cleaner.
add_custom_target(${PROJECT_NAME}-prepare_test
COMMAND cmake -E copy_directory ${PROJECT_SOURCE_DIR}/test ${CMAKE_CURRENT_BINARY_DIR}
- COMMAND cmake -E chdir test/deep python deep.py)
+ COMMAND cmake -E chdir test/deep "${PYTHON_EXECUTABLE}" deep.py)
if(TARGET ${PROJECT_NAME}-utest)
add_dependencies(${PROJECT_NAME}-utest ${PROJECT_NAME}-prepare_test)
endif()
diff --git a/test/test/utest.cpp b/test/test/utest.cpp
index c72ab39..8b3b0dd 100644
--- a/test/test/utest.cpp
+++ b/test/test/utest.cpp
@@ -1,10 +1,10 @@
/*
* Copyright (c) 2008, Willow Garage, Inc.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
@@ -13,7 +13,7 @@
* * Neither the name of Willow Garage, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -60,7 +60,7 @@ TEST(rospack, reentrant)
ASSERT_EQ((int)output_list.size(), 4);
ret = rp.run(std::string("list"));
ASSERT_EQ(ret, 0);
- output = rp.getOutput();
+ output = rp.getOutput();
boost::trim(output);
boost::split(output_list, output, boost::is_any_of("\n"));
ASSERT_EQ((int)output_list.size(), 4);
@@ -80,13 +80,13 @@ TEST(rospack, multiple_rospack_objects)
ret = rp.run(std::string("list-names"));
ASSERT_EQ(ret, 0);
std::vector<std::string> output_list;
- output = rp.getOutput();
+ output = rp.getOutput();
boost::trim(output);
boost::split(output_list, output, boost::is_any_of("\n"));
ASSERT_EQ((int)output_list.size(), 4);
ret = rp.run(std::string("list"));
ASSERT_EQ(ret, 0);
- output = rp.getOutput();
+ output = rp.getOutput();
boost::trim(output);
boost::split(output_list, output, boost::is_any_of("\n"));
ASSERT_EQ((int)output_list.size(), 4);
@@ -102,13 +102,13 @@ TEST(rospack, multiple_rospack_objects)
ret = rp2.run(std::string("list-names"));
ASSERT_EQ(ret, 0);
output_list.clear();
- output = rp2.getOutput();
+ output = rp2.getOutput();
boost::trim(output);
boost::split(output_list, output, boost::is_any_of("\n"));
ASSERT_EQ((int)output_list.size(), 4);
ret = rp2.run(std::string("list"));
ASSERT_EQ(ret, 0);
- output = rp2.getOutput();
+ output = rp2.getOutput();
boost::trim(output);
boost::split(output_list, output, boost::is_any_of("\n"));
ASSERT_EQ((int)output_list.size(), 4);
@@ -134,8 +134,7 @@ int main(int argc, char **argv)
char buf[1024];
std::string rr = std::string(getcwd(buf, sizeof(buf))) + "/test2";
- setenv("ROS_ROOT", rr.c_str(), 1);
- unsetenv("ROS_PACKAGE_PATH");
+ setenv("ROS_PACKAGE_PATH", rr.c_str(), 1);
char path[PATH_MAX];
if(getcwd(path,sizeof(path)))
{
diff --git a/test/test/utest.py.in b/test/test/utest.py.in
index c3620fa..09679b9 100644
--- a/test/test/utest.py.in
+++ b/test/test/utest.py.in
@@ -40,7 +40,6 @@ import sys
import platform
from subprocess import Popen, PIPE
-ROS_ROOT = 'ROS_ROOT'
ROS_PACKAGE_PATH = 'ROS_PACKAGE_PATH'
ROS_LANG_DISABLE = 'ROS_LANG_DISABLE'
ROSPACK_PATH = "@CATKIN_DEVEL_PREFIX@/bin/rospack"
@@ -83,15 +82,10 @@ class RospackTestCase(unittest.TestCase):
# Some tests change CWD
os.chdir(initial_cwd)
- ## runs rospack with ROS_ROOT set to ./test and ROS_PACKAGE_PATH unset
+ ## runs rospack with ROS_PACKAGE_PATH set to ./test
## @return int, str: return code, stdout
- def _run_rospack(self, ros_root, ros_package_path, pkgname, command):
+ def _run_rospack(self, ros_package_path, pkgname, command):
env = os.environ.copy()
- if ros_root is not None:
- env[ROS_ROOT] = ros_root
- else:
- if ROS_ROOT in env:
- del env[ROS_ROOT]
if ros_package_path is not None:
env[ROS_PACKAGE_PATH] = ros_package_path
elif ROS_PACKAGE_PATH in env:
@@ -135,44 +129,44 @@ class RospackTestCase(unittest.TestCase):
## @return str: stdout
def run_rospack(self, pkgname, command):
- ros_root = os.path.abspath('test')
- return self._run_rospack(ros_root, None, pkgname, command)[1]
+ rpp = os.path.abspath('test')
+ return self._run_rospack(rpp, pkgname, command)[1]
## @return str: stdout
- def erun_rospack(self, ros_root, ros_package_path, pkgname, command):
- return self._run_rospack(ros_root, ros_package_path, pkgname, command)[1]
+ def erun_rospack(self, ros_package_path, pkgname, command):
+ return self._run_rospack(ros_package_path, pkgname, command)[1]
- ## runs rospack with ROS_ROOT set to ./test and ROS_PACKAGE_PATH unset
+ ## runs rospack with ROS_PACKAGE_PATH set to ./test
## @return int: status code
def run_rospack_status(self, pkgname, command):
- ros_root = os.path.abspath('test')
- return self._run_rospack(ros_root, None, pkgname, command)[0]
+ rpp = os.path.abspath('test')
+ return self._run_rospack(rpp, pkgname, command)[0]
## @return int: status code
- def erun_rospack_status(self, ros_root, ros_package_path, pkgname, command):
- return self._run_rospack(ros_root, ros_package_path, pkgname, command)[0]
+ def erun_rospack_status(self, ros_package_path, pkgname, command):
+ return self._run_rospack(ros_package_path, pkgname, command)[0]
## assert that rospack fails on the specified args
def rospack_fail(self, package, command):
- ros_root = os.path.abspath('test')
- code, stdout, stderr = self._run_rospack(ros_root, None, package, command)
+ rpp = os.path.abspath('test')
+ code, stdout, stderr = self._run_rospack(rpp, package, command)
self.assertNotEquals(0, code, "rospack [%s %s] should have failed. \n\nstdout[%s] \n\nstderr[%s]"%(command, package, stdout, stderr))
- ## assert that rospack fails on the specified args. includes ROS_ROOT and ROS_PACKAGE_PATH
- def erospack_fail(self, ros_root, ros_package_path, package, command):
- code, stdout, stderr = self._run_rospack(ros_root, ros_package_path, package, command)
+ ## assert that rospack fails on the specified args. includes ROS_PACKAGE_PATH
+ def erospack_fail(self, ros_package_path, package, command):
+ code, stdout, stderr = self._run_rospack(ros_package_path, package, command)
self.assertNotEquals(0, code, "rospack [%s %s] should have failed instead of returning status code 0. \n\nstdout[%s] \n\nstderr[%s]"%(command, package, stdout, stderr))
## assert that rospack succeeds on the specified args
def rospack_succeed(self, package, command):
- ros_root = os.path.abspath('test')
- status_code, stdout, stderr = self._run_rospack(ros_root, None, package, command)
+ rpp = os.path.abspath('test')
+ status_code, stdout, stderr = self._run_rospack(rpp, package, command)
self.assertEquals(0, status_code, '"rospack %s %s" failed with status code [%s] instead of succeeding with [0]. \n\nstdout[%s] \n\nstderr[%s]'%(command, package, status_code, stdout, stderr))
## assert that rospack succeeds on the specified args
- def erospack_succeed(self, ros_root, ros_package_path, package, command):
- status_code, stdout, stderr = self._run_rospack(ros_root, ros_package_path, package, command)
- self.assertEquals(0, status_code, "rospack [%s %s, env ROS_ROOT=%s ROS_PACKAGE_PATH=%s] failed with status code [%s] instead of succeeding with [0]. \n\nstdout[%s] \n\nstderr[%s]"%(command, package, ros_root, ros_package_path, status_code, stdout, stderr))
+ def erospack_succeed(self, ros_package_path, package, command):
+ status_code, stdout, stderr = self._run_rospack(ros_package_path, package, command)
+ self.assertEquals(0, status_code, "rospack [%s %s, env ROS_PACKAGE_PATH=%s] failed with status code [%s] instead of succeeding with [0]. \n\nstdout[%s] \n\nstderr[%s]"%(command, package, ros_package_path, status_code, stdout, stderr))
# helper routine that does return value validation where the return value from
# rospack is an unordered, line-separated list
@@ -185,16 +179,16 @@ class RospackTestCase(unittest.TestCase):
self.failIf(set(retlist) ^ set(retactual), "rospack %s %s failed: [%s] vs [%s]"%(command, package, retlist, retactual))
self.assertEquals('\n'.join(retlist), '\n'.join(retactual))
- # variant of check_ordered_list that allows specifying ros_root and ros_package_path.
+ # variant of check_ordered_list that allows specifying ros_package_path.
# helper routine that does return value validation where the return value from
# rospack is an unordered, line-separated list
def echeck_ordered_list(self, command, tests):
- for retlist, ros_root, ros_package_path, package in tests:
+ for retlist, ros_package_path, package in tests:
expected = set(retlist)
- self.erospack_succeed(ros_root, ros_package_path, package, command)
- retval = self.erun_rospack(ros_root, ros_package_path, package, command)
+ self.erospack_succeed(ros_package_path, package, command)
+ retval = self.erun_rospack(ros_package_path, package, command)
retactual = [v for v in retval.split('\n') if v]
- self.failIf(set(retlist) ^ set(retactual), "[env %s %s] rospack %s %s failed: [%s] vs [%s]"%(ros_root, ros_package_path, command, package, retlist, retactual))
+ self.failIf(set(retlist) ^ set(retactual), "[env %s] rospack %s %s failed: [%s] vs [%s]"%(ros_package_path, command, package, retlist, retactual))
# variant that does not require ordering among the return values
def check_unordered_list(self, command, tests):
@@ -208,10 +202,10 @@ class RospackTestCase(unittest.TestCase):
# variant that does not require ordering among the return values
def echeck_unordered_list(self, command, tests):
- for retlist, ros_root, ros_package_path, package in tests:
+ for retlist, ros_package_path, package in tests:
expected = set(retlist)
- self.erospack_succeed(ros_root, ros_package_path, package, command)
- retval = self.erun_rospack(ros_root, ros_package_path, package, command)
+ self.erospack_succeed(ros_package_path, package, command)
+ retval = self.erun_rospack(ros_package_path, package, command)
retactual = [v for v in retval.split('\n') if v]
self.failIf(set(retlist) ^ set(retactual), "rospack %s %s failed: [%s] vs [%s]"%(command, package, retlist, retactual))
#self.assertEquals('\n'.join(retlist), '\n'.join(retactual))
@@ -258,9 +252,11 @@ class RospackTestCase(unittest.TestCase):
# Make sure we write to ROS_HOME, #2812.
d = tempfile.mkdtemp()
+ self.assertEquals(0, len(os.listdir(d)))
os.environ['ROS_HOME'] = d
- cache_path = os.path.join(d,'rospack_cache')
self.rospack_succeed(None, "profile")
+ self.assertEquals(1, len(os.listdir(d)))
+ cache_path = os.path.join(d, os.listdir(d)[0])
self.assertEquals(True, os.path.exists(cache_path))
# Make sure we auto-create ROS_HOME
shutil.rmtree(d)
@@ -379,30 +375,11 @@ class RospackTestCase(unittest.TestCase):
################################################################################
## ENVIRONMENT TEST
- def test_no_ros_root(self):
- testp = os.path.abspath('test')
- self.erospack_succeed(None, testp, "deps", "deps")
-
- def test_bad_ros_root(self):
- non_existent1 = os.path.abspath('non_existent1')
- testp = os.path.abspath("test")
- self.erospack_succeed(non_existent1, testp, "deps", "deps")
-
- ## test rospack with ROS_ROOT=ROS_PACKAGE_PATH
- def test_ros_root_ros_package_path_identical(self):
- #implicitly depending on the deps test here
- #set ros_package_path to be identical to ros_root
+ ## test rospack with ROS_PACKAGE_PATH set
+ def test_ros_package_path(self):
testp = os.path.abspath('test')
tests = [
- (["base", "base_two"], testp, testp, "deps"),
- ]
- self.echeck_ordered_list("deps", tests)
-
- ## test rospack with ROS_PACKAGE_PATH set to the empty string
- def test_empty_ros_package_path(self):
- testp = os.path.abspath('test')
- tests = [
- (["base", "base_two"], testp, '', "deps"),
+ (["base", "base_two"], testp, "deps"),
]
self.echeck_ordered_list("deps", tests)
@@ -413,10 +390,10 @@ class RospackTestCase(unittest.TestCase):
test2p = os.path.abspath('test2')
testp_roslang = os.path.join(testp, 'roslang')
test2p_roslang = os.path.join(test2p, 'roslang')
- tests = [([testp_roslang], teste, ':'.join([testp, test2p]), "roslang"),
- ([testp_roslang], teste, ':'.join([testp, test2p_roslang]), "roslang"),
- ([testp_roslang], teste, ':'.join([testp_roslang, test2p]), "roslang"),
- ([testp_roslang], teste, ':'.join([testp_roslang, test2p_roslang]), "roslang")]
+ tests = [([testp_roslang], teste + ':' + ':'.join([testp, test2p]), "roslang"),
+ ([testp_roslang], teste + ':' + ':'.join([testp, test2p_roslang]), "roslang"),
+ ([testp_roslang], teste + ':' + ':'.join([testp_roslang, test2p]), "roslang"),
+ ([testp_roslang], teste + ':' + ':'.join([testp_roslang, test2p_roslang]), "roslang")]
self.echeck_unordered_list('find', tests)
## tests rpp vs rr precedence
@@ -425,10 +402,10 @@ class RospackTestCase(unittest.TestCase):
test2p = os.path.abspath('test2')
test3p = os.path.abspath('test3')
tests = [
- (["test"], testp, test2p, "precedence1"),
- (["test2"], test2p, testp, "precedence1"),
- (["test2"], testp, "%s:%s"%(test2p, test3p), "precedence2"),
- (["test3"], testp, "%s:%s"%(test3p, test2p), "precedence2"),
+ (["test"], testp + ':' + test2p, "precedence1"),
+ (["test2"], test2p + ':' + testp, "precedence1"),
+ (["test2"], testp + ':' + "%s:%s"%(test2p, test3p), "precedence2"),
+ (["test3"], testp + ':' + "%s:%s"%(test3p, test2p), "precedence2"),
]
self.echeck_ordered_list('libs-only-l', tests)
@@ -437,8 +414,8 @@ class RospackTestCase(unittest.TestCase):
testp = os.path.abspath('test')
test2p = os.path.abspath('test2')
test3p = os.path.abspath('test3')
- self.erospack_succeed(testp, None, None, 'list-duplicates')
- self.erospack_succeed(testp, '%s:%s'%(test2p,test3p), None, 'list-duplicates')
+ self.erospack_succeed(testp, None, 'list-duplicates')
+ self.erospack_succeed(testp + ':' + '%s:%s'%(test2p,test3p), None, 'list-duplicates')
# test ability to point ros_package_path directly at package
def test_ros_package_path_direct_package(self):
@@ -448,8 +425,8 @@ class RospackTestCase(unittest.TestCase):
# point directly at precedence 2/3
rpp = ':'.join([os.path.join(test2p, 'precedence2'),os.path.join(test3p, 'precedence3')])
tests = [
- (["test2"], testp, rpp, "precedence2"),
- (["test3"], testp, rpp, "precedence3"),
+ (["test2"], testp + ':' + rpp, "precedence2"),
+ (["test3"], testp + ':' + rpp, "precedence3"),
]
self.echeck_ordered_list('libs-only-l', tests)
@@ -460,13 +437,13 @@ class RospackTestCase(unittest.TestCase):
# Add a trailing slash, to make sure that it gets removed
test3p = os.path.abspath('test3') + '/'
tests = [
- (["base","base_two"], testp, "::%s:::"%testp, "deps"),
- (["base","base_two"], testp, "::", "deps"),
+ (["base","base_two"], testp + ':' + "::%s:::"%testp, "deps"),
+ (["base","base_two"], testp + ':' + "::", "deps"),
]
self.echeck_ordered_list('deps', tests)
tests = [
- (["test"], testp, ":::%s:"%test2p, "precedence1"),
- (["test2"],testp, "::%s::%s::"%(test2p,test3p), "precedence2"),
+ (["test"], testp + ':' + ":::%s:"%test2p, "precedence1"),
+ (["test2"],testp + ':' + "::%s::%s::"%(test2p,test3p), "precedence2"),
]
self.echeck_ordered_list("libs-only-l", tests)
@@ -475,35 +452,31 @@ class RospackTestCase(unittest.TestCase):
test2p = os.path.abspath('test2')
non_existentp = os.path.abspath('test')
tests = [
- (["test"], testp, non_existentp, "precedence1"),
- (["test2"],testp, ":%s:%s"%(non_existentp, test2p), "precedence2"),
- (["test2"],testp, ":%s:%s"%(test2p, non_existentp), "precedence2"),
+ (["test"], testp + ':' + non_existentp, "precedence1"),
+ (["test2"],testp + ':' + ":%s:%s"%(non_existentp, test2p), "precedence2"),
+ (["test2"],testp + ':' + ":%s:%s"%(test2p, non_existentp), "precedence2"),
]
self.echeck_ordered_list("libs-only-l", tests)
# Test rospack from within a package
def test_ros_in_package(self):
pwd = os.getcwd()
- ros_root = os.path.join(pwd, 'test')
+ rpp = os.path.join(pwd, 'test')
os.chdir(os.path.abspath(os.path.join('test', 'deps')))
- self.erospack_succeed(ros_root, None, None, 'depends1')
- self.echeck_unordered_list('depends1', [(["base", "base_two"], ros_root, None, None)])
+ self.erospack_succeed(rpp, None, 'depends1')
+ self.echeck_unordered_list('depends1', [(["base", "base_two"], rpp, None)])
# Check what happens when we're in an unlinked directory
d = tempfile.mkdtemp()
os.chdir(d)
os.rmdir(d)
- self.erospack_fail(ros_root, None, None, 'depends1')
+ self.erospack_fail(rpp, None, 'depends1')
os.chdir(pwd)
################################################################################
## rospack list
- def _rospack_list(self, ros_root, ros_package_path):
+ def _rospack_list(self, ros_package_path):
env = os.environ.copy()
- if ros_root is not None:
- env[ROS_ROOT] = ros_root
- else:
- del env[ROS_ROOT]
if ros_package_path is not None:
env[ROS_PACKAGE_PATH] = ros_package_path
elif ROS_PACKAGE_PATH in env:
@@ -527,33 +500,30 @@ class RospackTestCase(unittest.TestCase):
## test rospack list on an empty tree
def test_rospack_list_empty(self):
- rr = os.path.abspath('test_empty')
- retcode, retval = self._rospack_list(rr, None)
+ rpp = os.path.abspath('test_empty')
+ retcode, retval = self._rospack_list(rpp)
self.assertEquals(0, retcode)
self.failIf(retval, "rospack list on empty directory returned value %s"%retval)
## test rospack depends-on1 in a directory that's not a package (#2556)
def test_rospack_depends_on_not_a_package(self):
pwd = os.getcwd()
- ros_root = os.path.abspath('test')
+ rpp = os.path.abspath('test')
os.chdir(os.path.abspath('/'))
- self.erospack_fail(ros_root, None, None, 'depends-on1')
+ self.erospack_fail(rpp, None, 'depends-on1')
os.chdir(pwd)
# test that rospack list removes duplicates
def test_rospack_list_dups(self):
# make sure result is same if ROS_ROOT=ROS_PACKAGE_PATH
- rr = os.path.abspath('structure_test')
- retcode, retval = self._rospack_list(rr, None)
+ rpp = os.path.abspath('structure_test')
+ retcode, retval = self._rospack_list(rpp)
self.assertEquals(0, retcode)
- retcode2, retval2 = self._rospack_list(rr, rr)
- self.assertEquals(0, retcode2)
- self.assertEquals(retval, retval2, "rospack list did not remove duplicates")
def test_rospack_list_no_rpp(self):
- rr = os.path.abspath('structure_test')
+ rpp = os.path.abspath('structure_test')
expected = structure_test.copy()
- retcode, retval = self._rospack_list(rr, None)
+ retcode, retval = self._rospack_list(rpp)
self.assertEquals(0, retcode)
self._check_rospack_list(expected, retval)
@@ -563,12 +533,8 @@ class RospackTestCase(unittest.TestCase):
################################################################################
## rospack list-names
- def _rospack_list_names(self, ros_root, ros_package_path):
+ def _rospack_list_names(self, ros_package_path):
env = os.environ.copy()
- if ros_root is not None:
- env[ROS_ROOT] = ros_root
- else:
- del env[ROS_ROOT]
if ros_package_path is not None:
env[ROS_PACKAGE_PATH] = ros_package_path
elif ROS_PACKAGE_PATH in env:
@@ -580,25 +546,25 @@ class RospackTestCase(unittest.TestCase):
## test rospack list-names on an empty tree
def test_rospack_list_names_empty(self):
- rr = os.path.abspath('test_empty')
- retcode, retval = self._rospack_list_names(rr, None)
+ rpp = os.path.abspath('test_empty')
+ retcode, retval = self._rospack_list_names(rpp)
self.assertEquals(0, retcode)
self.failIf(retval, "rospack list-names on empty directory returned value %s"%retval)
# test that rospack list removes duplicates
def test_rospack_list_names_dups(self):
# make sure result is same if ROS_ROOT=ROS_PACKAGE_PATH
- rr = os.path.abspath('structure_test')
- retcode, retval = self._rospack_list_names(rr, None)
+ rpp = os.path.abspath('structure_test')
+ retcode, retval = self._rospack_list_names(rpp)
self.assertEquals(0, retcode)
- retcode2, retval2 = self._rospack_list_names(rr, rr)
+ retcode2, retval2 = self._rospack_list_names(rpp)
self.assertEquals(0, retcode2)
self.assertEquals(retval, retval2, "rospack list-names did not remove duplicates")
def test_rospack_list_names_no_rpp(self):
- rr = os.path.abspath('structure_test')
+ rpp = os.path.abspath('structure_test')
expected = set(structure_test.copy().keys())
- retcode, retval = self._rospack_list_names(rr, None)
+ retcode, retval = self._rospack_list_names(rpp)
self.assertEquals(0, retcode)
self.assertEquals(expected, set(retval.split()))
@@ -610,30 +576,30 @@ class RospackTestCase(unittest.TestCase):
## test rospack find on non-existent package
def test_rospack_find_fail(self):
- rr = os.path.abspath('test_empty')
- self.erospack_fail(rr, None, 'package', 'find')
+ rpp = os.path.abspath('test_empty')
+ self.erospack_fail(rpp, 'package', 'find')
## test rospack find with ros_package_path set directly to a package
def test_rospack_find_direct(self):
testp = os.path.abspath('test')
package1p = os.path.abspath(os.path.join('structure_test', 'package1'))
- self.erospack_succeed(testp, package1p, 'package1', 'find')
- self.assertEquals(package1p, self.erun_rospack(testp, package1p, 'package1', 'find'))
+ self.erospack_succeed(testp + ':' + package1p, 'package1', 'find')
+ self.assertEquals(package1p, self.erun_rospack(testp + ':' + package1p, 'package1', 'find'))
## test rospack find with ros_package_path set directly to a package,
## where that package contains a rospack_nosubdirs file, #3191.
def test_rospack_find_direct_with_rospack_nosubdirs(self):
testp = os.path.abspath('test')
package2p = os.path.abspath(os.path.join('structure_test', 'package2'))
- self.erospack_succeed(testp, package2p, 'package2', 'find')
- self.assertEquals(package2p, self.erun_rospack(testp, package2p, 'package2', 'find'))
+ self.erospack_succeed(testp + ':' + package2p, 'package2', 'find')
+ self.assertEquals(package2p, self.erun_rospack(testp + ':' + package2p, 'package2', 'find'))
def test_rospack_find_no_rpp(self):
- rr = os.path.abspath('structure_test')
+ rpp = os.path.abspath('structure_test')
expected = structure_test.copy()
for package,path in expected.items():
- self.erospack_succeed(rr, None, package, 'find')
- self.assertEquals(path, os.path.abspath(self.erun_rospack(rr, None, package, 'find')))
+ self.erospack_succeed(rpp, package, 'find')
+ self.assertEquals(path, os.path.abspath(self.erun_rospack(rpp, package, 'find')))
#TODO: symlink test
#TODO: test with ros package path
@@ -701,13 +667,13 @@ class RospackTestCase(unittest.TestCase):
def test_circular(self):
testp = os.path.abspath("test")
- self.erospack_fail(testp, os.path.abspath("test_circular/cycle0"), "self_ref", "deps")
- self.erospack_fail(testp, os.path.abspath("test_circular/cycle1"), "friend1", "deps")
- self.erospack_fail(testp, os.path.abspath("test_circular/cycle1"), "friend2", "deps")
- self.erospack_fail(testp, os.path.abspath("test_circular/cycle2"), "friend1", "deps")
- self.erospack_fail(testp, os.path.abspath("test_circular/cycle2"), "friend2", "deps")
- self.erospack_fail(testp, os.path.abspath("test_circular/cycle2"), "friend3", "deps")
- self.erospack_fail(testp, os.path.abspath("test_circular/cycle2"), "friend3", "depends-on")
+ self.erospack_fail(testp + ':' + os.path.abspath("test_circular/cycle0"), "self_ref", "deps")
+ self.erospack_fail(testp + ':' + os.path.abspath("test_circular/cycle1"), "friend1", "deps")
+ self.erospack_fail(testp + ':' + os.path.abspath("test_circular/cycle1"), "friend2", "deps")
+ self.erospack_fail(testp + ':' + os.path.abspath("test_circular/cycle2"), "friend1", "deps")
+ self.erospack_fail(testp + ':' + os.path.abspath("test_circular/cycle2"), "friend2", "deps")
+ self.erospack_fail(testp + ':' + os.path.abspath("test_circular/cycle2"), "friend3", "deps")
+ self.erospack_fail(testp + ':' + os.path.abspath("test_circular/cycle2"), "friend3", "depends-on")
def test_lflags_backquote(self):
self.rospack_succeed("backquote", "libs-only-l")
@@ -827,12 +793,8 @@ class RospackTestCase(unittest.TestCase):
self.assertEquals(expected,
self.run_rospack("deps_higher", "deps-indent"))
- def _rospack_langs(self, ros_root, ros_package_path, ros_lang_disable):
+ def _rospack_langs(self, ros_package_path, ros_lang_disable):
env = os.environ.copy()
- if ros_root is not None:
- env[ROS_ROOT] = ros_root
- else:
- del env[ROS_ROOT]
if ros_package_path is not None:
env[ROS_PACKAGE_PATH] = ros_package_path
elif ROS_PACKAGE_PATH in env:
@@ -847,8 +809,8 @@ class RospackTestCase(unittest.TestCase):
return p.returncode, retval.strip().decode('ascii')
def test_langs(self):
- rr = os.path.abspath('test')
- retcode, retval = self._rospack_langs(rr, None, None)
+ rpp = os.path.abspath('test')
+ retcode, retval = self._rospack_langs(rpp, None)
self.assertEquals(0, retcode)
# No guarantees on ordering of lang result
l = retval.split()
@@ -857,9 +819,9 @@ class RospackTestCase(unittest.TestCase):
self.assertEquals(s, expected)
def test_langs_disable(self):
- rr = os.path.abspath('test')
+ rpp = os.path.abspath('test')
disable = 'rosfoo'
- retcode, retval = self._rospack_langs(rr, None, disable)
+ retcode, retval = self._rospack_langs(rpp, disable)
self.assertEquals(0, retcode)
# No guarantees on ordering of lang result
l = retval.split()
@@ -868,8 +830,8 @@ class RospackTestCase(unittest.TestCase):
self.assertEquals(s, expected)
def test_langs_empty(self):
- rr = os.path.abspath('test2')
- retcode, retval = self._rospack_langs(rr, None, None)
+ rpp = os.path.abspath('test2')
+ retcode, retval = self._rospack_langs(rpp, None)
self.assertEquals(0, retcode)
self.failIf(retval, "rospack langs on empty directory returned value %s"%retval)
@@ -892,14 +854,14 @@ class RospackTestCase(unittest.TestCase):
# Test that -q option suppresses errors, #3177.
def test_quiet_option(self):
- ros_root = os.path.abspath('test')
+ rpp = os.path.abspath('test')
# With -q: look for non-existent package, make sure that it fails, yet
# produces nothing on stderr.
- status_code, stdout, stderr = self._run_rospack(ros_root, None, 'nonexistentpackage', 'find -q')
+ status_code, stdout, stderr = self._run_rospack(rpp, 'nonexistentpackage', 'find -q')
self.assertNotEquals(0, status_code)
self.assertEquals(0, len(stderr))
# Without -q: look for non-existent package, make sure that it fails,
# and produces somthing on stderr.
- status_code, stdout, stderr = self._run_rospack(ros_root, None, 'nonexistentpackage', 'find')
+ status_code, stdout, stderr = self._run_rospack(rpp, 'nonexistentpackage', 'find')
self.assertNotEquals(0, status_code)
self.assertNotEquals(0, len(stderr))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/ros/rospack.git
More information about the debian-science-commits
mailing list