Skip to content

Writethrough when saving files, add Netkan tests#4392

Merged
HebaruSan merged 19 commits into
KSP-CKAN:masterfrom
HebaruSan:fix/json-nulls
Jun 14, 2025
Merged

Writethrough when saving files, add Netkan tests#4392
HebaruSan merged 19 commits into
KSP-CKAN:masterfrom
HebaruSan:fix/json-nulls

Conversation

@HebaruSan
Copy link
Copy Markdown
Member

Motivations

  • Since f33b901, we have known about the possibility that GUIConfig.xml could become corrupted. Generally this takes the form of the entire file being populated by NUL characters on Windows, and we've seen it a few times for JSON files as well. Some browsing of StackExchange indicated that this may be due to filesystem caching and buffering of various sorts delaying the file from being written past the point of something that stops it.
  • Now that we have coverage tracking as of Coverage #4383, Coveralls makes it possible to browse the source tree looking for untested code. It would be nice to get our overall coverage as close to 100% as possible, and currently it's hovering around a fairly pathetic 30.3%. There are several files in Netkan/Sources and Netkan/Transformers that have no coverage at all currently and can be tested fairly easily.
  • Coveralls currently includes _build, Tests, and ConsoleUI in the coverage stats, which is not optimal:
    • _build isn't a real code folder.
    • Tests does not contain any end-user app code.
    • ConsoleUI is purely UI and not testable because the difference between good or bad outcomes are things like, does that look right? does it make sense to a human?
      (A similar argument could be made for GUI, but there we do actually have a few meaningful tests and could conceivably add more, especially of the Model classes.)

Changes

  • Now we use FileOptions.WriteThrough to strongly encourage Windows to actually write our various JSON files to disk when we ask it to. This might conceivably slow down response times slightly in some cases, but that trade-off is worth the benefit of greater robustness.
  • New tests are added for several Netkan transformer classes.
  • Tests involving hosts other than SpaceDock are removed from the FlakyNetwork category to increase coverage. Of all the servers we use, SpaceDock is currently the only one truly deserving of that label.
  • Some existing tests of Netkan transformer classes are refactored to increase their coverage, chiefly by replacing the mockup of API objects with mockups of IHttpService objects that are then used by the real API objects.
  • The ConsoleUI, Tests, and _build folders are now excluded from Coveralls (hopefully).

@HebaruSan HebaruSan added Enhancement New features or functionality GUI Issues affecting the interactive GUI Core (ckan.dll) Issues affecting the core part of CKAN Windows Issues specific for Windows Tests Issues affecting the internal tests labels Jun 14, 2025
@coveralls
Copy link
Copy Markdown

coveralls commented Jun 14, 2025

Pull Request Test Coverage Report for Build 15655094302

Details

  • 19 of 32 (59.38%) changed or added relevant lines in 18 files are covered.
  • 6 unchanged lines in 6 files lost coverage.
  • Overall coverage decreased (-3.2%) to 27.151%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Core/Configuration/StabilityToleranceConfig.cs 0 1 0.0%
Core/GameInstance.cs 1 2 50.0%
Core/Games/KerbalSpaceProgram2.cs 0 1 0.0%
Core/Registry/Tags/ModuleTagList.cs 0 1 0.0%
Core/SuppressedCompatWarningIdentifiers.cs 0 1 0.0%
Core/Types/CkanModule.cs 0 1 0.0%
Core/Types/Labels/ModuleLabelList.cs 0 1 0.0%
Core/Types/TimeLog.cs 0 1 0.0%
GUI/URLHandlers.cs 0 1 0.0%
Netkan/Program.cs 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
Core/Configuration/StabilityToleranceConfig.cs 1 29.41%
Core/GameInstance.cs 1 53.21%
Core/Registry/Tags/ModuleTagList.cs 1 0.0%
Core/SuppressedCompatWarningIdentifiers.cs 1 0.0%
Core/Types/Labels/ModuleLabelList.cs 1 42.86%
Core/Types/TimeLog.cs 1 33.33%
Totals Coverage Status
Change from base Build 15540484445: -3.2%
Covered Lines: 8041
Relevant Lines: 31165

💛 - Coveralls

@HebaruSan
Copy link
Copy Markdown
Member Author

HebaruSan commented Jun 14, 2025

I'm sorry that you're mad, @coveralls, but the previous number was inflated due to the former inclusion of Tests.
27% is a more accurate baseline, and the effort to increase coverage in specific areas of Netkan was mildly successful.

imageimage

@HebaruSan HebaruSan merged commit a01cebc into KSP-CKAN:master Jun 14, 2025
5 of 6 checks passed
@HebaruSan HebaruSan deleted the fix/json-nulls branch June 14, 2025 19:26
@HebaruSan HebaruSan mentioned this pull request Jun 17, 2025
@HebaruSan HebaruSan mentioned this pull request Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Core (ckan.dll) Issues affecting the core part of CKAN Enhancement New features or functionality GUI Issues affecting the interactive GUI Tests Issues affecting the internal tests Windows Issues specific for Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants