Skip to content

Commit

Permalink
Add debug information for working directory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
thk123 committed Mar 27, 2018
1 parent 770eb2a commit 39282a6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions unit/testing-utils/load_java_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <goto-programs/lazy_goto_model.h>

#include <java_bytecode/java_bytecode_language.h>
#include <util/file_util.h>

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

// Log the working directory to help people identify the common error
// of wrong working directory (should be the `unit` directory when running
// the unit tests).
std::string path = get_current_working_directory();
INFO("Working directory: " << path);

// if this fails it indicates the class was not loaded
// Check your working directory and the class path is correctly configured
// as this often indicates that one of these is wrong.
Expand Down

0 comments on commit 39282a6

Please sign in to comment.