From c4b7f19a6b8d187da362e2e0dc6bd5e44d593a74 Mon Sep 17 00:00:00 2001 From: wmtan Date: Wed, 11 Nov 2015 08:43:03 -0600 Subject: [PATCH] Fix FileInPath test --- FWCore/ParameterSet/src/FileInPath.cc | 6 ++++++ FWCore/PythonParameterSet/test/fip.txt | 1 + .../test/makepset_t.cppunit.cc | 21 ++++++++++--------- FWCore/PythonParameterSet/test/ufip.txt | 1 + 4 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 FWCore/PythonParameterSet/test/fip.txt create mode 100644 FWCore/PythonParameterSet/test/ufip.txt diff --git a/FWCore/ParameterSet/src/FileInPath.cc b/FWCore/ParameterSet/src/FileInPath.cc index 77c230724a9c2..0be5ea9bfea05 100644 --- a/FWCore/ParameterSet/src/FileInPath.cc +++ b/FWCore/ParameterSet/src/FileInPath.cc @@ -387,6 +387,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(); } diff --git a/FWCore/PythonParameterSet/test/fip.txt b/FWCore/PythonParameterSet/test/fip.txt new file mode 100644 index 0000000000000..a52b9dba51d13 --- /dev/null +++ b/FWCore/PythonParameterSet/test/fip.txt @@ -0,0 +1 @@ +Dummy file for the FileInPath test. diff --git a/FWCore/PythonParameterSet/test/makepset_t.cppunit.cc b/FWCore/PythonParameterSet/test/makepset_t.cppunit.cc index ac2a60916fa88..447a21d50711f 100644 --- a/FWCore/PythonParameterSet/test/makepset_t.cppunit.cc +++ b/FWCore/PythonParameterSet/test/makepset_t.cppunit.cc @@ -95,7 +95,7 @@ void testmakepset::secsourceAux() { PythonProcessDesc builder(config); std::shared_ptr 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"); @@ -149,7 +149,7 @@ void testmakepset::usingBlockAux() { PythonProcessDesc builder(config); std::shared_ptr 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"); @@ -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"; @@ -197,7 +197,7 @@ void testmakepset::fileinpathAux() { // Create the ParameterSet object from this configuration string. PythonProcessDesc builder(config); std::shared_ptr 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("fip"); @@ -205,19 +205,20 @@ void testmakepset::fileinpathAux() { CPPUNIT_ASSERT(innerps.existsAs("extraneous")); CPPUNIT_ASSERT(!innerps.existsAs("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("topo"); CPPUNIT_ASSERT(topo.location() != edm::FileInPath::Local); @@ -256,7 +257,7 @@ void testmakepset::fileinpathAux() { unlink(tmpout.c_str()); std::shared_ptr 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("fip2"); diff --git a/FWCore/PythonParameterSet/test/ufip.txt b/FWCore/PythonParameterSet/test/ufip.txt new file mode 100644 index 0000000000000..a52b9dba51d13 --- /dev/null +++ b/FWCore/PythonParameterSet/test/ufip.txt @@ -0,0 +1 @@ +Dummy file for the FileInPath test.