ucrcsedept / galah

An automated grading system geared towards processing computer programming assignments.
Apache License 2.0
42 stars 8 forks source link

Unittest module doesn't like compiling a main.cpp that lacks a using namespace std. #411

Open itsjohncs opened 10 years ago

itsjohncs commented 10 years ago

Compiling a main.cpp file without a using namespace std; will make the unittest module throw an exception.

import interact.unittest
a = interact.unittest.load_files(["main.cpp"]

With the above script, the following C++ code will cause the script to raise an error.

// main.cpp
int main() {
    return 1;
}

The error is:

Traceback (most recent call last):
  File "main.py", line 3, in <module>
    a = interact.unittest.load_files(["main.cpp"])
  File "/home/csmajs/jsull003/swig/interact/unittest.py", line 312, in load_files
    _generate_shared_libraries(modules, temp_dir)
  File "/home/csmajs/jsull003/swig/interact/unittest.py", line 112, in _generate_shared_libraries
    stderr = captured.stderr.read()
interact.unittest.CouldNotCompile: Could not compile extension module.
[Lots of stderr output omitted]

The following C++ code does not error:

// main.cpp
using namespace std;

int main() {
    return 1;
}

This is probably preventable, not sure what would cause this yet.