<commit_before>/*
 * Copyright (c) 2008-2010 Digital Bazaar, Inc. All rights reserved.
 */
#include "bitmunk/test/Tester.h"

#include "bitmunk/common/Logging.h"
#include "monarch/config/ConfigManager.h"
#include "monarch/io/FileList.h"
#include "monarch/rt/Platform.h"
#include "monarch/test/Test.h"

using namespace std;
using namespace bitmunk::common;
using namespace bitmunk::node;
using namespace bitmunk::test;
using namespace monarch::app;
using namespace monarch::config;
using namespace monarch::io;
using namespace monarch::kernel;
using namespace monarch::rt;

#define BITMUNK_TESTER_CONFIG_ID   "bitmunk.test.Tester.config.base"

Tester::Tester()
{
}

Tester::~Tester()
{
}

Node* Tester::loadNode(monarch::test::TestRunner& tr, const char* unitTest)
{
   Node* rval = NULL;

   // get app and config manager
   App* app = tr.getApp();
   ConfigManager* cm = app->getConfigManager();

   // save config manager state
   cm->saveState();

   // set TMP_DIR keyword, update BITMUNK_HOME
   string tmp;
   assert(File::getTemporaryDirectory(tmp));
   cm->setKeyword("TMP_DIR", tmp.c_str());
   cm->setKeyword("BITMUNK_HOME", File::join(tmp.c_str(), "test").c_str());

   // add test config
   cm->addConfigFile(app->getConfig()
      ["bitmunk.apps.tester.Tester"]["configPath"]->getString());
   assertNoException();

   // add optional unit test config
   if(unitTest != NULL)
   {
      Config cfg = app->getConfig()["bitmunk.apps.tester.Tester"];
      string path = unitTest;
      path.append(".config");
      path = File::join(cfg["unitTestConfigPath"]->getString(), path.c_str());
      cm->addConfigFile(path.c_str());
      assertNoException();
   }

   // get the path to the node module
   Config cfg = app->getConfig();
   assertNoException();
   assert(!cfg.isNull());

   // load node module
   assert(cfg["test"]->hasMember("nodeModule"));
   const char* nodeModule = cfg["test"]["nodeModule"]->getString();
   MicroKernel* k = app->getKernel();
   MicroKernelModule* mod = k->loadMicroKernelModule(nodeModule);
   if(mod != NULL)
   {<commit_msg>Removed code that changed BITMUNK_HOME keyword. It should be configured in the Tester App config by setting monarch.app.Core home.<commit_after>/*
 * Copyright (c) 2008-2010 Digital Bazaar, Inc. All rights reserved.
 */
#include "bitmunk/test/Tester.h"

#include "bitmunk/common/Logging.h"
#include "monarch/config/ConfigManager.h"
#include "monarch/io/FileList.h"
#include "monarch/rt/Platform.h"
#include "monarch/test/Test.h"

using namespace std;
using namespace bitmunk::common;
using namespace bitmunk::node;
using namespace bitmunk::test;
using namespace monarch::app;
using namespace monarch::config;
using namespace monarch::io;
using namespace monarch::kernel;
using namespace monarch::rt;

Tester::Tester()
{
}

Tester::~Tester()
{
}

Node* Tester::loadNode(monarch::test::TestRunner& tr, const char* unitTest)
{
   Node* rval = NULL;

   // get app and config manager
   App* app = tr.getApp();
   ConfigManager* cm = app->getConfigManager();

   // save config manager state
   cm->saveState();

   // set TMP_DIR keyword
   string tmp;
   assert(File::getTemporaryDirectory(tmp));
   cm->setKeyword("TMP_DIR", tmp.c_str());

   // add test config
   cm->addConfigFile(app->getConfig()
      ["bitmunk.apps.tester.Tester"]["configPath"]->getString());
   assertNoException();

   // add optional unit test config
   if(unitTest != NULL)
   {
      Config cfg = app->getConfig()["bitmunk.apps.tester.Tester"];
      string path = unitTest;
      path.append(".config");
      path = File::join(cfg["unitTestConfigPath"]->getString(), path.c_str());
      cm->addConfigFile(path.c_str());
      assertNoException();
   }

   // get the path to the node module
   Config cfg = app->getConfig();
   assertNoException();
   assert(!cfg.isNull());

   // load node module
   assert(cfg["test"]->hasMember("nodeModule"));
   const char* nodeModule = cfg["test"]["nodeModule"]->getString();
   MicroKernel* k = app->getKernel();
   MicroKernelModule* mod = k->loadMicroKernelModule(nodeModule);
   if(mod != NULL)
   {
{'fraction_non_alphanumeric': 0.155517578125, 'fraction_numerical': 0.00390625, 'mean_word_length': 4.239130434782608, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1504824', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1318, 'n_words': 300}