Skip to content

Commit

Permalink
connect to SMem DB in init CLI command
Browse files Browse the repository at this point in the history
Previously a simple

smem --init
smem --clear

at the beginning of a source file would fail and prevent the rest of the file
from sourcing. Connect to the DB in the init CLI command so that any following
actions can access the DB. I believe this is the intuitive behavior, and I don't
see anything in the manual that would indicate that this incorrect.
  • Loading branch information
garfieldnate committed Aug 23, 2023
1 parent 343e367 commit 2e32249
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ compile_commands.json

# NUNIT
*.VisualState.xml
TestResult.xml
TestResults.xml

# Build Results of an ATL Project
[Dd]ebugPS/
Expand Down
8 changes: 5 additions & 3 deletions Core/CLI/src/cli_smem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,11 @@ bool CommandLineInterface::DoSMem(const char pOp, const std::string* pArg1, cons
}
else if (pOp == 'i')
{
/* Don't think we need clear out anything else any more */

thisAgent->SMem->reinit();
if (thisAgent->SMem->connected()) {
thisAgent->SMem->reinit();
} else {
thisAgent->SMem->attach();
}

PrintCLIMessage("Semantic memory system re-initialized.");
if (thisAgent->SMem->settings->append_db->get_value() == on)
Expand Down
10 changes: 10 additions & 0 deletions UnitTests/SoarTestAgents/testRegression370.soar
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://github.com/SoarGroup/Soar/issues/370
# Make sure that smem --init connects smem DB so that --clear doesn't raise an error.
smem --init
smem --clear

sp {pass
(state <S1>)
-->
(succeeded)
}
7 changes: 7 additions & 0 deletions UnitTests/SoarUnitTests/MiscTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ void MiscTests::testWrongAgentWmeFunctions()

}

void MiscTests::testRegression370()
{
source("testRegression370.soar");
agent->RunSelf(5000);
SoarHelper::init_check_to_find_refcount_leaks(agent);
}

void MiscTests::testRHSRand()
{
kernel->AddRhsFunction("failed", Handlers::MyRhsFunctionFailureHandler, 0) ;
Expand Down
2 changes: 2 additions & 0 deletions UnitTests/SoarUnitTests/MiscTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class MiscTests : public FunctionalTestHarness

TEST(testWrongAgentWmeFunctions, -1)
void testWrongAgentWmeFunctions();
TEST(testRegression370, -1)
void testRegression370();
TEST(testRHSRand, -1)
void testRHSRand();
TEST(testMultipleKernels, -1)
Expand Down

0 comments on commit 2e32249

Please sign in to comment.