From 39282a6ca1470575f1d8d10fca84d6f2539bb436 Mon Sep 17 00:00:00 2001 From: thk123 Date: Mon, 19 Mar 2018 11:26:38 +0000 Subject: [PATCH] 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. --- unit/testing-utils/load_java_class.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/unit/testing-utils/load_java_class.cpp b/unit/testing-utils/load_java_class.cpp index c8da44814cc..f198008dff4 100644 --- a/unit/testing-utils/load_java_class.cpp +++ b/unit/testing-utils/load_java_class.cpp @@ -17,6 +17,7 @@ #include #include +#include /// Go through the process of loading, type-checking and finalising loading a /// specific class file to build the symbol table. The functions are converted @@ -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.