[Bug] Headless tests: the data folder a test gives `MainWindowViewModel` does not reach its core, which reads the real per-user `settings.cfg`
Maintainers usually reply within 5 days
Assessment
This issue has not been assessed yet.
Description
What happened
MainWindowViewModel has a constructor for tests that takes a data folder. The view model's own paths go there, but the core it builds does not get the folder. That core looks up the real per-user Genie5 folder and loads the settings.cfg it finds there.
So a headless test that builds a core through the view model can depend on the settings of whoever runs it, and a test that connects would write its logs beside the real ones.
What you expected
The folder a test hands to the constructor should be the core's folder too.
Steps to reproduce
-
Add this test to
tests/Genie.App.HeadlessTests:[AvaloniaFact] public async Task The_core_a_test_builds_uses_the_tests_data_folder() { var dir = Path.Combine(Path.GetTempPath(), "genie_folder_" + Guid.NewGuid().ToString("N")); Directory.CreateDirectory(Path.Combine(dir, "Config")); File.WriteAllText(Path.Combine(dir, "Config", "settings.cfg"), "#config {prompt} {only-in-the-test-folder}\n"); var vm = new MainWindowViewModel(startup: null, dataDirectoryOverride: dir); vm.Command.CommandText = "#echo hello"; // the first typed command builds the core vm.Command.SubmitCommand.Execute().Subscribe(); Dispatcher.UIThread.RunJobs(); var core = Assert.IsType<Genie.Core.GenieCore>(vm.Core); try { Assert.StartsWith(Path.GetFullPath(dir), Path.GetFullPath(core.Config.ConfigDir)); Assert.Equal("only-in-the-test-folder", core.Config.GetSetting("prompt")); } finally { await core.DisposeAsync(); } } -
Run it. It fails: the core's
ConfigDiris the per-user folder, not the test's.
The existing suite shows it too: dotnet test tests/Genie.App.HeadlessTests reads ~/.local/share/Genie5/Config/settings.cfg (its access time moves during the run). All 359 tests still pass with my settings, and the suite writes nothing there today.
Environment
- OS + version: Ubuntu 26.04
- Genie 5 version:
mainas of d1373a5 (5.0.1-beta.5) - Install type: built from source
- Connection mode: not connected (the steps need no connection)
Logs / session capture
Failed Genie.App.HeadlessTests.ReportProbeTests.The_core_a_test_builds_uses_the_tests_data_folder [361 ms]
Assert.StartsWith() Failure: String start does not match
String: "~/.local/share/Genie5/Config"
Expected start: "/tmp/genie_folder_070faa89b2fc416d98edb97"···
Anything else
Cause, as far as I can read it:
- The constructor passes
dataDirectoryOverrideto its ownLocalDirectoryServiceonly. - Where the core is built (
new GenieCore(dataDirectoryOverride: …)), the argument is the connected profile's data directory or null. With null the core resolves the per-user folder itself.
The same is true of main as of d1373a5.
Workaround: a test can build its GenieCore directly with dataDirectoryOverride, when it does not need the view model.
I have a fix with tests (the constructor's folder is passed on to the core when the profile names none; a real start passes no folder and is unchanged), and a pull request follows.
- Dominant language
- C#
- Stars
- 2
- Forks
- 5
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 22
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GenieClient/Genie5
-
bug
Difficulty 1/5 1-3 hours Newbie friendliness 90/100
GenieClient/Genie5#496 ·
Maintainers usually reply within 5 days
-
enhancement g4-regression
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
GenieClient/Genie5#494 ·
Maintainers usually reply within 5 days
-
area:ui-dock enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
GenieClient/Genie5#462 ·
Maintainers usually reply within 5 days
-
area:mapper bug est:<1d P2
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
GenieClient/Genie5#449 · 1 comment ·
Maintainers usually reply within 5 days
-
[Bug] Maps ▸ Update from Official Repo / Repair Maps give no notification of success or failurePossibly taken A pull request linked to this issue is open or already merged. Openarea:mapper area:updater bug est:<1d P3
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
GenieClient/Genie5#423 · 1 assignee ·
Maintainers usually reply within 5 days
All issues in GenieClient/Genie5
Similar issues
-
documentation good first issue kind:task level:starter size:s
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Arggon/ArggonStores#66 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
[Tool] MockAPIOpenhas-image has-license has-readme new-tool ready-to-approve repo-verified
Difficulty 1/5 Under an hour Newbie friendliness 72/100
shanselman/TinyToolTown#956 ·
Maintainers usually reply within 2 days
-
bug frontend
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
[Bug]: Native build script prints a traceback when Git is missing from PATHPossibly taken @Jaisuryan-web claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
KnifeLemon/Filee#1953 ·
Maintainers usually reply within 1 day