( ! dirEntry.
IsFile() ) {
106 stringname =
file.GetName();
115 const stringsFileName =
file.GetName();
116vector<string> vecFileNamePieces;
117 NStr::Split( sFileName,
".", vecFileNamePieces );
118BOOST_REQUIRE(vecFileNamePieces.size() == 3);
120 stringsTestName = vecFileNamePieces[0];
121BOOST_REQUIRE(!sTestName.empty());
122 stringsObjType = vecFileNamePieces[1];
123BOOST_REQUIRE(!sObjType.empty());
124 stringsFileType = vecFileNamePieces[2];
125BOOST_REQUIRE(!sFileType.empty());
128(*m_pTestNameToInfoMap)[vecFileNamePieces[0]];
131list<string> supportedObjectTypes{
132 "align",
"align-set",
"annot",
"bioseq",
"bioset",
"entry"};
133 autotypeIt = std::find(supportedObjectTypes.begin(), supportedObjectTypes.end(), sObjType);
134 if(typeIt == supportedObjectTypes.end()) {
135BOOST_FAIL(
"Unknown object type "<< sObjType <<
".");
137test_info_to_load.
mObjType= sObjType;
154BOOST_FAIL(
"Unknown file type "<< sFileName <<
".");
177BOOST_FAIL(
"input file "<<
input<<
" does not exist.");
181cerr <<
"Creating new test case from "<<
input<<
" ..."<< endl;
219 while(!pI->EndOfData()) {
230 for(
const auto& alignIt: pAlignSet->
Get()) {
247pEntry->
SetSet(*pBioseq_set);
259cerr <<
" Produced new GFF3 file "<<
output<<
"."<< endl;
260cerr <<
" ... Done."<< endl;
267 constvector<string> kEmptyStringVec;
279 const string& sName = name_to_info_it->first +
280 "."+ name_to_info_it->second.mObjType;
289cerr <<
"Testing "<< testInfo.
mInFile.
GetName() <<
" against "<<
310 if(testInfo.
mObjType==
"annot") {
317 else if(testInfo.
mObjType==
"entry") {
325 else if(testInfo.
mObjType==
"align") {
331 while(!pI->EndOfData()) {
338 else if(testInfo.
mObjType==
"align-set") {
342 for(
const auto& alignIt: pAlignSet->
Get()) {
347 else if(testInfo.
mObjType==
"bioseq") {
369BOOST_ERROR(
"Error: "<< sTestName <<
" failed due to post processing diffs.");
375 if(!success && keep) {
380BOOST_ERROR(
"Error: "<< sTestName <<
" failed due to error handling diffs.");
389arg_descrs->AddDefaultKey(
"test-dir",
"TEST_FILE_DIRECTORY",
390 "Set the root directory under which all test files can be found.",
393arg_descrs->AddDefaultKey(
"update-case",
"UPDATE_CASE",
394 "Produce .asn and .error files from given name for new or updated test case.",
397arg_descrs->AddFlag(
"update-all",
398 "Update all test cases to current reader code (dangerous).",
400arg_descrs->AddFlag(
"keep-diffs",
401 "Keep output files that are different from the expected.",
414 CDirtest_cases_dir( args[
"test-dir"].AsDirectory() );
415BOOST_REQUIRE_MESSAGE( test_cases_dir.
IsDir(),
416 "Cannot find dir: "<< test_cases_dir.
GetPath() );
418 boolupdate_all = args[
"update-all"].AsBoolean();
424 stringupdate_case = args[
"update-case"].AsString();
425 if(!update_case.empty()) {
430 constvector<string> kEmptyStringVec;
442 const string& sName = name_to_info_it->first;
443 const STestInfo& testInfo = name_to_info_it->second;
444cout <<
"Verifying: "<< sName << endl;
453 const string& sName = name_to_info_it->first;
454 const STestInfo& testInfo = name_to_info_it->second;
456cout <<
"Running test: "<< sName << endl;
458BOOST_CHECK_NO_THROW(
sRunTest(sName, testInfo, args[
"keep-diffs"]));
static TRegisterLoaderInfo RegisterInObjectManager(CObjectManager &om, CReader *reader=0, CObjectManager::EIsDefault is_default=CObjectManager::eDefault, CObjectManager::TPriority priority=CObjectManager::kPriority_NotSet)
bool WriteAnnot(const CSeq_annot &annot, const string &asmblyName="", const string &asmblyAccession="") override
Write a trailer marking the end of a parsing context.
bool WriteBioseqHandle(CBioseq_Handle bsh, const string &asmblyName="", const string &asmblyAccession="") override
Write Bioseq contained in given handle Essentially, will write all features that live on the given Bi...
bool WriteSeqEntryHandle(CSeq_entry_Handle seh, const string &asmblyName="", const string &asmblyAccession="") override
Write Seq-entry contained in a given handle.
bool WriteAlign(const CSeq_align &, const string &asmblyName="", const string &asmblyAccession="") override
Write a raw Seq-align to the internal output stream.
bool WriteFooter() override
Write a file trailer.
bool WriteHeader() override
Write a file header.
static CNcbiApplication * Instance(void)
Singleton method.
TTestNameToInfoMap * m_pTestNameToInfoMap
void operator()(const CDirEntry &dirEntry)
CTestNameToInfoMapLoader(TTestNameToInfoMap *pTestNameToInfoMap, const string &extInput, const string &extOutput, const string &extErrors)
static void test_type(TDSSOCKET *tds, TDSCOLUMN *col)
static SQLCHAR output[256]
static int RunTests(void)
Code to iterate through all tests to run.
static char test_name[128]
virtual const CArgs & GetArgs(void) const
Get parsed command line arguments.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
@ eString
An arbitrary string.
@ eDirectory
Name of file directory.
void FindFilesInDir(const CDir &dir, const vector< string > &masks, const vector< string > &masks_subdir, TFindFunc &find_func, TFindFiles flags=fFF_Default)
Find files in the specified directory.
virtual bool Remove(TRemoveFlags flags=eRecursive) const
Remove a directory entry.
bool IsDir(EFollowLinks follow=eFollowLinks) const
Check whether a directory entry is a directory.
bool CompareTextContents(const string &file, ECompareText mode, size_t buf_size=0) const
Compare files contents in text form.
bool IsFile(EFollowLinks follow=eFollowLinks) const
Check whether a directory entry is a file.
static string GetTmpName(ETmpFileCreationMode mode=eTmpFileGetName)
Get temporary file name.
static string ConcatPath(const string &first, const string &second)
Concatenate two parts of the path for the current OS.
string GetName(void) const
Get the base entry name with extension (if any).
const string & GetPath(void) const
Get entry path.
virtual bool Copy(const string &new_path, TCopyFlags flags=fCF_Default, size_t buf_size=0) const
Copy the entry to a location specified by "new_path".
virtual bool Exists(void) const
Check existence of file.
@ fCF_Overwrite
The following flags define what to do when the destination entry already exists:
@ fFF_Recursive
descend into sub-dirs
@ fFF_Default
default behavior
@ eSerial_AsnText
ASN.1 text.
static CObjectIStream * Open(ESerialDataFormat format, CNcbiIstream &inStream, bool deleteInStream)
Create serial object reader and attach it to an input stream.
TLoader * GetLoader(void) const
Get pointer to the loader.
CBioseq_Handle AddBioseq(CBioseq &bioseq, TPriority pri=kPriority_Default, EExist action=eExist_Throw)
Add bioseq, return bioseq handle.
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
CSeq_entry_Handle AddTopLevelSeqEntry(CSeq_entry &top_entry, TPriority pri=kPriority_Default, EExist action=eExist_Default)
Add seq_entry, default priority is higher than for defaults or loaders Add object to the score with p...
void AddDefaults(TPriority pri=kPriority_Default)
Add default data loaders from object manager.
IO_PREFIX::ofstream CNcbiOfstream
Portable alias for ofstream.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
const Tdata & Get(void) const
Get the member data.
TSet & SetSet(void)
Select the variant.
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...
Utility stuff for more convenient using of Boost.Test library.
BOOST_AUTO_TEST_CASE(RunTests)
const string extErrors("errors")
void sUpdateAll(CDir &test_cases_dir)
map< TTestName, STestInfo > TTestNameToInfoMap
const string dirTestFiles("gff3writer_test_cases")
CGff3Writer * sGetWriter(CScope &scope, CNcbiOstream &ostr)
const string extOutput("gff3")
void sUpdateCase(CDir &test_cases_dir, const string &test_name)
const string extInput("asn")
const string extKeep("new")
void sRunTest(const string &sTestName, const STestInfo &testInfo, bool keep)
NCBITEST_INIT_CMDLINE(arg_descrs)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4