diffix / reference

Reference implementation for the Open Diffix anonymization mechanism.
https://www.open-diffix.org
Other
3 stars 0 forks source link

Silence the console output of `dotnet test` #268

Closed pdobacz closed 3 years ago

pdobacz commented 3 years ago

After https://github.com/diffix/reference/pull/267 running the tests will print irrelevant lines of results:

user@user-komp:~/sources/opendiffix/reference$ dotnet fantomas -r . >/dev/null&& dotnet test --filter "FullyQualifiedName~OpenDiffix.CLI.ProgramTests"
  Determining projects to restore...

...snip...

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
"count"
206
{
  "columns": [
    {
      "name": "count",
      "type": "integer"
    }
  ],
  "rows": [
    [
      197.0
    ]
  ]
}
"age","city","company_name","count"
30,"Berlin","Alpha Centauri Inc.",2
{
  "name": "OpenDiffix Reference implementation",
  "version": {
    "version": "0.0.974",
    "commit_number": 974,
    "branch": "raw/piotr/add-cli-tests",
    "sha": "7303106",
    "dirty_build": true
  }
}
{
  "version": {
    "name": "OpenDiffix Reference implementation",
    "version": {
      "version": "0.0.974",
      "commit_number": 974,
      "branch": "raw/piotr/add-cli-tests",
      "sha": "7303106",
      "dirty_build": true
    }
  },
  "time": "Monday, October 25, 2021",
  "query_results": [
    {
      "success": false,
      "error": "unable to open database file"
    },
    {
      "success": false,
      "error": "unable to open database file"
    },
    {
      "success": false,
      "error": "unable to open database file"
    }
  ]
}
"count"
509
"count"
206

Passed!  - Failed:     0, Passed:    10, Skipped:     0, Total:    10, Duration: 215 ms - /home/user/sources/opendiffix/reference/src/OpenDiffix.CLI.Tests/bin/Debug/net5.0/OpenDiffix.CLI.Tests.dll (net5.0)
No test matches the given testcase filter `FullyQualifiedName~OpenDiffix.CLI.ProgramTests` in /home/user/sources/opendiffix/reference/src/OpenDiffix.Core.Tests/bin/Debug/net5.0/OpenDiffix.Core.Tests.dll

do something about this.

Ideas:

cristianberneanu commented 3 years ago

Another option: create a separate function for arguments handling that also receives an output handler. From the main program call it with printfn, from tests call it with a dummy handler.

cristianberneanu commented 3 years ago

refactor Program, so that the console output is returned instead of printed

On a second thought, returning the output and ignoring it during tests makes more sense.