File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -88,11 +88,12 @@ Tracer::Tracer(const std::string n)
8888void Tracer::addSignalToTrace (const SignalBase<int > &sig,
8989 const string &filename) {
9090 dgDEBUGIN (15 );
91+ // openFile may throw so it should be called first.
92+ if (namesSet)
93+ openFile (sig, filename);
9194 toTraceSignals.push_back (&sig);
9295 dgDEBUGF (15 , " %p" , &sig);
9396 names.push_back (filename);
94- if (namesSet)
95- openFile (sig, filename);
9697 triger.addDependency (sig);
9798 dgDEBUGOUT (15 );
9899}
Original file line number Diff line number Diff line change @@ -65,11 +65,16 @@ BOOST_AUTO_TEST_CASE(test_tracer) {
6565 std::string basename (" my-tracer" );
6666 std::string suffix (" .dat" );
6767
68- // / Test openfiles
6968 atracer.setBufferSize (1 <<14 );
70- atracer.openFiles (rootdir, basename, suffix);
7169
72- // / Add trace by name
70+ // Check that an exception is thrown if the filename is invalid.
71+ atracer.openFiles (rootdir, " invalid/filename" , suffix);
72+ BOOST_CHECK_THROW (atracer.addSignalToTraceByName (" my-entity.out_double" , " output" ),
73+ ExceptionTraces);
74+
75+ // Test openfiles
76+ atracer.openFiles (rootdir, basename, suffix);
77+ // Add trace by name
7378 atracer.addSignalToTraceByName (" my-entity.out_double" , " output" );
7479
7580 // / Add trace by name
You can’t perform that action at this time.
0 commit comments