Skip to content
Snippets Groups Projects

Add TestCreateTwoOperations

Merged John Tourtellott requested to merge john.tourtellott/smtk:two-operation-tasks into master

Adds test to generate project with simple task set with some fixes to task I/O.

Note that this MR might have conflicts with !2922 (merged). Recommend merging !2922 (merged) first.

TwoOperations-v3

Edited by John Tourtellott

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
109 110 project->setLocation(filename);
110 111 project->resources().setManager(this->managers()->get<smtk::resource::Manager::Ptr>());
111 112 project->operations().setManager(this->managers()->get<smtk::operation::Manager::Ptr>());
113 smtk::task::Registrar::registerTo(project->taskManager().shared_from_this());
  • This is not enough; it only registers smtkCore's tasks to the project manager. If there are really problems registering task types, then the solution is to have the plugin manager iterate over all the Registrar classes that have a registerTo(const std::shared_ptr<task::Manager>&) method and invoke each of them. I believe this would be smtk::plugin::Manager::instance()->registerPluginsTo(project->taskManager().shared_from_this()).

  • Hmmm.... your comment leaves me the impression that I need to create the (project and) task manager before reading the file so that I can call the registerPlugins method before reading the file. Is that the case?

    Sooooo..... I need to call both functions?

    smtk::task::Registrar::registerTo(project->taskManager().shared_from_this());
    smtk::plugin::Manager::instance()->registerPluginsTo(project->taskManager().shared_from_this());
    Edited by John Tourtellott
  • You should only need to do the latter (it should invoke the former).

  • I might have to go back to gdb and/or printf's. Adding the registerPluginsTo() call and leaving out the registerTo() method makes the test fail.

    158: Test command: /home/local/KHQ/john.tourtellott/projects/cmb-master/build/smtk/bin/UnitTests_smtk_project_testing_cxx "TestCreateTwoOperationProject"
    158: Test timeout computed to be: 120
    158: Deleting existing directory "/home/local/KHQ/john.tourtellott/projects/cmb-master/build/smtk/Testing/Temporary/TwoOperations/"
    158: Imported operattion "math_op.MathOp"
    158: Wrote /home/local/KHQ/john.tourtellott/projects/cmb-master/build/smtk/Testing/Temporary/TwoOperations/TwoOperations.project.smtk
    158: ## TEST FAILURE ##
    158: 
    158:   Input project wrong number of tasks; should be 5 not 0
    158: 
    158: ## TEST FAILURE ##
    158: terminate called after throwing an instance of 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >'
    1/1 Test #158: TestCreateTwoOperationProject ....Subprocess aborted***Exception:   0.46 sec

    modelbuilder must be initializing something that the test is not...

  • I finally figured out why calling smtk::plugin::Manager::instance()->registerPluginsTo() in test programs does not get the default task types registered. After some reverse engineering:

    Part 1: Why TestCreateTwoOperations does NOT register tasks. In brief, when calling smtk::plugin::Manager::instance()->registerPluginsTo(), its m_clients member data (std::vector) is empty and the method skips the part that would have called the code to register task types.

    Part 2: So how does modelbuilder register tasks and (therefore) successfully create projects with task managers? When modelbuilder starts, the import/registration of the vtkPVPlugin ends up calling functions with names like smtk::plugin::init::smtk_resource_Registrar(). These functions are generated during the build process and essentially populate the m_clients member in smtk::plugin::Manager.

    So, mimicking the code in smtkPluginInitializersmtk_task_Registrar.cxx at the start of the test program eliminated the need for explicitly registering task types. (The change is just a one-line instantiation of type smtk::plugin::Client<smtk::task::Registrar, smtk::task::Manager>.)

    Maybe some wordsmithed version of this lore should be put in smtk docs somewhere. In the meantime, this gets me over the hump when creating projects with tasks. I still need to look into a problem with task managers in projects that are read from file.

  • John Tourtellott changed this line in version 7 of the diff

    changed this line in version 7 of the diff

  • Yes, TJ's strength was not documentation. We really should look into properly documenting smtk/plugin.

  • Please register or sign in to reply
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading