Skip to content

Commit 39282a6

Browse files
author
thk123
committed
Add debug information for working directory
The most common error when running unit tests is forgetting to set the working direcotory. This causes problems when loading java classes so to minimize this we print the working directory in the catch output.
1 parent 770eb2a commit 39282a6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

unit/testing-utils/load_java_class.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <goto-programs/lazy_goto_model.h>
1818

1919
#include <java_bytecode/java_bytecode_language.h>
20+
#include <util/file_util.h>
2021

2122
/// Go through the process of loading, type-checking and finalising loading a
2223
/// specific class file to build the symbol table. The functions are converted
@@ -128,6 +129,12 @@ symbol_tablet load_java_class(
128129
const typet &class_type=class_symbol.type;
129130
REQUIRE(class_type.id()==ID_struct);
130131

132+
// Log the working directory to help people identify the common error
133+
// of wrong working directory (should be the `unit` directory when running
134+
// the unit tests).
135+
std::string path = get_current_working_directory();
136+
INFO("Working directory: " << path);
137+
131138
// if this fails it indicates the class was not loaded
132139
// Check your working directory and the class path is correctly configured
133140
// as this often indicates that one of these is wrong.

0 commit comments

Comments
 (0)