Permalink
Browse files

Merge pull request #123 from rgsilva/master

Testrunner Windows port (MSVC)
  • Loading branch information...
2 parents ca4e6fa + e6e0cb9 commit 0081343fb8335ae1421959cecb793050f152307f @rgsilva rgsilva committed Feb 20, 2012
Showing with 390 additions and 9 deletions.
  1. +0 −2 CMakeLists.txt
  2. +1 −0 compiler/compiler.cc
  3. +9 −4 extra/testrunner.cc
  4. +7 −3 extra/testrunner.h
  5. +1 −0 interpreter/driver.cc
  6. +372 −0 win32/dirent.h
View
@@ -178,5 +178,3 @@ set_directory_properties(PROPERTIES
set(CPACK_GENERATOR "STGZ;TBZ2;TGZ;ZIP")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Clever programming language")
include(CPack)
-
-
View
@@ -170,6 +170,7 @@ void Compiler::buildIR() {
*/
ast::UnscopedBlockNode* Compiler::importFile(Driver& driver, const CString* file,
ast::Identifier* alias) {
+
driver.parseFile(file->str());
return new ast::UnscopedBlockNode(alias, static_cast<ast::BlockNode*>(getAST()));
View
@@ -29,6 +29,11 @@
#include <cstdlib>
#include "testrunner.h"
+#ifdef CLEVER_MSVC
+#define popen _popen
+#define pclose _pclose
+#endif
+
TestRunner::~TestRunner() {
std::vector<std::string>::iterator it;
@@ -38,12 +43,12 @@ TestRunner::~TestRunner() {
}
void TestRunner::show_result(void) const {
- timeval end_time;
+ clock_t end_time;
double duration;
- gettimeofday(&end_time, NULL);
+ end_time = clock();
- duration = (end_time.tv_sec - start_time.tv_sec) + (end_time.tv_usec - start_time.tv_usec)/1000000.0;
+ duration = (end_time - start_time) / CLOCKS_PER_SEC;
std::cout << "-----------------------------------" << std::endl;
std::cout << "Tests: " << files.size() << std::endl;
@@ -132,7 +137,7 @@ void TestRunner::run(void) {
}
#else
command = std::string("clever.exe -f ") + tmp_file + " 2>&1";
- fp = popen(command.c_str(), "r");
+ fp = _popen(command.c_str(), "r");
#endif
if (fread(result, 1, sizeof(result)-1, fp) == 0 && ferror(fp) != 0) {
View
@@ -29,13 +29,17 @@
#define CLEVER_TESTRUNNER_H
#include <vector>
+#include <ctime>
+#ifndef CLEVER_WIN32
#include <dirent.h>
-#include <sys/time.h>
+#else
+#include <win32/dirent.h>
+#endif
#include <pcrecpp.h>
class TestRunner {
unsigned int pass, fail, leak, flags;
- timeval start_time;
+ clock_t start_time;
std::vector<std::string> files;
std::vector<std::string> tmp_files;
@@ -47,7 +51,7 @@ class TestRunner {
public:
enum { FAIL_ONLY = 1 };
- TestRunner() : pass(0), fail(0), leak(0), flags(0), valgrind(false) { gettimeofday(&start_time, NULL); }
+ TestRunner() : pass(0), fail(0), leak(0), flags(0), valgrind(false) { start_time = clock(); }
~TestRunner();
std::string read_file(const char*) const;
View
@@ -98,6 +98,7 @@ void Driver::readFile(std::string& source) const {
source += '\n';
}
+ filep.clear();
filep.close();
}
Oops, something went wrong.

0 comments on commit 0081343

Please sign in to comment.