Skip to content

Commit

Permalink
TEMP: Debug .NET test failures DO NOT MERGE
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Aug 20, 2023
1 parent e19bd47 commit 294c965
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,9 @@ jobs:
run: dotnet build
working-directory: interfaces/dotnet
- name: Test the .NET interface
run: dotnet test
run: |
dotnet test
cat Cantera.Tests/bin/Debug/net6.0/debuglog.txt
working-directory: interfaces/dotnet
- name: Run the .NET samples
run: |
Expand Down
2 changes: 2 additions & 0 deletions include/cantera/base/ExternalLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class ExternalLogger : public Logger
{
public:
explicit ExternalLogger(LogCallback writer) {
std::ofstream dbg("debuglog.txt", std::ios_base::app);
dbg << "[C++] Creating External Logger at address " << (size_t) this << std::endl;
if (writer == nullptr) {
throw CanteraError("ExternalLogger::ExternalLogger",
"Argument “writer” must not be null!");
Expand Down
6 changes: 5 additions & 1 deletion include/cantera/base/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "ct_defs.h"

#include <iostream>
#include <fstream>

namespace Cantera
{
Expand Down Expand Up @@ -41,7 +42,10 @@ class Logger
{
public:
//! Constructor - empty
Logger() {}
Logger() {
std::ofstream dbg("debuglog.txt", std::ios_base::app);
dbg << "[C++] Creating Logger at address " << (size_t) this << std::endl;
}

//! Destructor - empty
virtual ~Logger() {}
Expand Down
4 changes: 2 additions & 2 deletions interfaces/dotnet/Cantera/src/Interop/LibCantera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ static partial class LibCantera

static LibCantera()
{
Console.Error.WriteLine($"[C#] Starting {nameof(LibCantera)} static constructor");
s_invokeMessageLoggedDelegate = Application.RaiseMessageLogged;
InteropUtil.CheckReturn(ct_setLogCallback(s_invokeMessageLoggedDelegate));

Thread.Sleep(2000);
Console.Error.WriteLine($"[C#] Finishing {nameof(LibCantera)} static constructor");
}
}
5 changes: 5 additions & 0 deletions src/base/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ int Application::Messages::getErrorCount()

void Application::Messages::setLogger(Logger* _logwriter)
{
std::ofstream dbg("debuglog.txt", std::ios_base::app);
dbg << "[C++] Initial Logger: " << (size_t) logwriter.get() << "; incoming Logger: " << (size_t) _logwriter << std::endl;
logwriter.reset(_logwriter);
}

Expand Down Expand Up @@ -109,6 +111,9 @@ void Application::ThreadMessages::removeThreadMessages()

Application::Application()
{
std::ofstream dbg("debuglog.txt", std::ios_base::app);
dbg << "[C++] Initializing Application object" << std::endl;

// install a default logwriter that writes to standard
// output / standard error
setDefaultDirectories();
Expand Down
3 changes: 3 additions & 0 deletions src/thermo/IdealGasPhase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
#include "cantera/thermo/IdealGasPhase.h"
#include "cantera/thermo/ThermoFactory.h"
#include "cantera/base/utilities.h"
#include <fstream>

namespace Cantera
{

IdealGasPhase::IdealGasPhase(const string& inputFile, const string& id_)
{
std::ofstream dbg("debuglog.txt", std::ios_base::app);
dbg << "[C++] Creating an IdealGasPhase object" << std::endl;
initThermoFile(inputFile, id_);
}

Expand Down

0 comments on commit 294c965

Please sign in to comment.