Skip to content

Commit 6074a23

Browse files
committed
Fix exec test.
[SVN r30669]
1 parent 9ceac3f commit 6074a23

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

test/Jamfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ test-suite python
7777
[
7878
run ../test/exec.cpp <lib>../build/boost_python
7979
: # program args
80-
: ../test/exec.py
80+
: exec.py
8181
: # requirements
8282
$(PYTHON_PROPERTIES)
8383
<define>BOOST_PYTHON_STATIC_LIB

test/exec.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
namespace python = boost::python;
1010

11+
std::string script;
12+
1113
// An abstract base class
1214
class Base : public boost::noncopyable
1315
{
@@ -79,12 +81,13 @@ void exec_test()
7981
std::cout << py.hello() << std::endl;
8082
}
8183

84+
// void exec_file_test(std::string const &script)
8285
void exec_file_test()
8386
{
8487
python::object main = python::import("__main__");
8588
python::dict global(main.attr("__dict__"));
8689
global.clear();
87-
python::object result = python::exec_file("exec.py", global, global);
90+
python::object result = python::exec_file(script.c_str(), global, global);
8891
std::string global_as_string = python::extract<std::string>(python::str(global))
8992
BOOST_EXTRACT_WORKAROUND;
9093
std::cout << global_as_string << std::endl;
@@ -97,8 +100,10 @@ void exec_test_error()
97100
python::object result = python::exec("print unknown \n", global, global);
98101
}
99102

100-
int main()
103+
int main(int argc, char **argv)
101104
{
105+
assert(argc == 2);
106+
script = argv[1];
102107
bool success = true;
103108
// Initialize the interpreter
104109
Py_Initialize();

0 commit comments

Comments
 (0)