Skip to content

Commit

Permalink
Fix FileInPath test
Browse files Browse the repository at this point in the history
  • Loading branch information
wmtan committed Nov 11, 2015
1 parent 50230de commit dc6bbf1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
7 changes: 7 additions & 0 deletions FWCore/ParameterSet/src/FileInPath.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/Utilities/interface/EDMException.h"
#include "FWCore/Utilities/interface/Parse.h"
#include <iostream>

namespace bf = boost::filesystem;

Expand Down Expand Up @@ -387,6 +388,12 @@ namespace edm
localTop_.clear();
}
}
if (releaseTop_ == localTop_) {
// RELEASETOP is the same as LOCALTOP. This means that the environment is set
// for the base release itself. So LOCALTOP actually contains the
// location of the base release.
localTop_.clear();
}
if (!envstring(DATATOP, dataTop_)) {
dataTop_.clear();
}
Expand Down
1 change: 1 addition & 0 deletions FWCore/PythonParameterSet/test/fip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dummy file for the FileInPath test.
21 changes: 11 additions & 10 deletions FWCore/PythonParameterSet/test/makepset_t.cppunit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ void testmakepset::secsourceAux() {
PythonProcessDesc builder(config);
std::shared_ptr<edm::ParameterSet> ps = builder.parameterSet();

CPPUNIT_ASSERT(0 != ps.get());
CPPUNIT_ASSERT(nullptr != ps.get());

// Make sure this ParameterSet object has the right contents
edm::ParameterSet const& mixingModuleParams = ps->getParameterSet("mix");
Expand Down Expand Up @@ -149,7 +149,7 @@ void testmakepset::usingBlockAux() {
PythonProcessDesc builder(config);
std::shared_ptr<edm::ParameterSet> ps = builder.parameterSet();

CPPUNIT_ASSERT(0 != ps.get());
CPPUNIT_ASSERT(nullptr != ps.get());

// Make sure this ParameterSet object has the right contents
edm::ParameterSet const& m1Params = ps->getParameterSet("m1");
Expand Down Expand Up @@ -186,8 +186,8 @@ void testmakepset::fileinpathAux() {
"process = cms.Process('PROD')\n"
"process.main = cms.PSet(\n"
" topo = cms.FileInPath('Geometry/TrackerSimData/data/trackersens.xml'),\n"
" fip = cms.FileInPath('FWCore/ParameterSet/python/Config.py'),\n"
" ufip = cms.untracked.FileInPath('FWCore/ParameterSet/python/Types.py'),\n"
" fip = cms.FileInPath('FWCore/PythonParameterSet/test/fip.txt'),\n"
" ufip = cms.untracked.FileInPath('FWCore/PythonParameterSet/test/ufip.txt'),\n"
" extraneous = cms.int32(12)\n"
")\n"
"process.source = cms.Source('EmptySource')\n";
Expand All @@ -197,27 +197,28 @@ void testmakepset::fileinpathAux() {
// Create the ParameterSet object from this configuration string.
PythonProcessDesc builder(config);
std::shared_ptr<edm::ParameterSet> ps = builder.parameterSet();
CPPUNIT_ASSERT(0 != ps.get());
CPPUNIT_ASSERT(nullptr != ps.get());

edm::ParameterSet const& innerps = ps->getParameterSet("main");
edm::FileInPath fip = innerps.getParameter<edm::FileInPath>("fip");
edm::FileInPath ufip = innerps.getUntrackedParameter<edm::FileInPath>("ufip");
CPPUNIT_ASSERT(innerps.existsAs<int>("extraneous"));
CPPUNIT_ASSERT(!innerps.existsAs<int>("absent"));
char *releaseBase = getenv("CMSSW_RELEASE_BASE");
bool localArea = (releaseBase != 0 && strlen(releaseBase) != 0);
char *localBase = getenv("CMSSW_BASE");
bool localArea = (releaseBase != nullptr && strlen(releaseBase) != 0 && strcmp(releaseBase, localBase));
if(localArea) {
CPPUNIT_ASSERT(fip.location() == edm::FileInPath::Local);
}
CPPUNIT_ASSERT(fip.relativePath() == "FWCore/ParameterSet/python/Config.py");
CPPUNIT_ASSERT(ufip.relativePath() == "FWCore/ParameterSet/python/Types.py");
CPPUNIT_ASSERT(fip.relativePath() == "FWCore/PythonParameterSet/test/fip.txt");
CPPUNIT_ASSERT(ufip.relativePath() == "FWCore/PythonParameterSet/test/ufip.txt");
std::string fullpath = fip.fullPath();
std::cerr << "fullPath is: " << fip.fullPath() << std::endl;
std::cerr << "copy of fullPath is: " << fullpath << std::endl;

CPPUNIT_ASSERT(!fullpath.empty());

std::string tmpout = fullpath.substr(0, fullpath.find("FWCore/ParameterSet/python/Config.py")) + "tmp.py";
std::string tmpout = fullpath.substr(0, fullpath.find("FWCore/PythonParameterSet/test/fip.txt")) + "tmp.py";

edm::FileInPath topo = innerps.getParameter<edm::FileInPath>("topo");
CPPUNIT_ASSERT(topo.location() != edm::FileInPath::Local);
Expand Down Expand Up @@ -256,7 +257,7 @@ void testmakepset::fileinpathAux() {
unlink(tmpout.c_str());
std::shared_ptr<edm::ParameterSet> ps2 = builder2.parameterSet();

CPPUNIT_ASSERT(0 != ps2.get());
CPPUNIT_ASSERT(nullptr != ps2.get());

edm::ParameterSet const& innerps2 = ps2->getParameterSet("main");
edm::FileInPath fip2 = innerps2.getParameter<edm::FileInPath>("fip2");
Expand Down
1 change: 1 addition & 0 deletions FWCore/PythonParameterSet/test/ufip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dummy file for the FileInPath test.

0 comments on commit dc6bbf1

Please sign in to comment.