Skip to content

Mock IOobject

Elwardi edited this page Nov 6, 2022 · 1 revision

Mocking IOobjects for no Disk interactions

It would be awesome to produce a mock for IOobjects-based were Read-Write are disabled. This prevents test writers from reading-from or writing-to case dictionaries, which could potentially result in better code.

Issues

  • Restricting writing is relatively easy (even through file/directory permissions).
  • But restricting readings proves to be difficult.
  • It's not obvious which class exactly to mock.
  • Avoiding the use of original IOobject functionality is not always avoidable (Eg. Creating time and mesh objects)
  • None of IOobject's methods are virtual, many are inline. It might prove extremely hard to mock such classes.

Possible solutions

  • If mocking is not the way to go, would shipping a modified core OpenFOAM lib solve this issue?
    • Still need to read the mesh through regular IOobject functionality; so its implementation must be kept.
    • Maybe add a mocked version - compile the mesh (finiteVolume?) with the original thing, and all other stuff with the mock?

At this point, messing the tests by reading from disk then fixing it seems far more feasible

Clone this wiki locally