KerbalAlarmClock test coverage and Alarm API completion#982
Merged
Conversation
The mod's AlarmTypeEnum has a ScienceLab value and its AlarmActionEnum has Custom and Converted values, none of which kRPC's AlarmType and AlarmAction enums could represent. Because the enum conversions throw on unknown values, reading Alarm.Type on a science lab alarm, or Alarm.Action on an alarm whose action is a custom combination or was converted from an old alarm, raised an error. Add the missing values to the enums, the conversion switches and the vendored KACWrapper, and list them in the API documentation ordering.
Add the alarm fields the wrapper omitted: Enabled, PlaySound, Triggered (reflecting the mod's internal field - streaming it or using it in an event expression is how a client observes an alarm firing), and the SupportsRepeat/SupportsRepeatPeriod flags that gate the repeat setters. Also fix three defects found while testing the class: Remaining always threw an invalid cast (the mod stores it as a KSPTimeSpan object, which the wrapper unboxed as a double) and is now computed from the alarm time; alarm equality compared wrapper object references, so the same alarm fetched twice compared unequal; and Remove left the object usable, reading stale data instead of failing - every member now throws a clean "Alarm does not exist" error after removal, matching the SpaceCenter alarm API.
Replace the three empty-state checks (which never created an alarm, so the whole Alarm class was untested) with a create/round-trip/remove suite: creation, list/name/type queries, attribute round-trips, repeat support flags, action presets (and the ignored Custom/Converted writes), vessel and transfer-body round-trips, alarm firing via Triggered, pinned enum member sets, and access-after-remove errors. Adds a minimal craft for the vessel round-trip. The service had no test or lint rules and was absent from //:test and //:lint; add the RemoteTech-style rules and the root entries.
djungelorm
force-pushed
the
kac-tests-and-api
branch
from
July 19, 2026 19:52
1dd0d7b to
dc7fdc1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The KerbalAlarmClock service had almost no test coverage (a single
Availablecheck that wasn't wired into the build) and itsAlarmclass had several gaps and defects, found by testing against a disassembled KerbalAlarmClock v3.14.0.0.Enum fixes.
Alarm.Typethrew for science lab alarms andAlarm.Actionthrew for alarms whose action doesn't match one of the presets; the missingAlarmType.ScienceLab,AlarmAction.CustomandAlarmAction.Convertedvalues are now mapped.Alarm class. Adds
Enabled,PlaySound,Triggered,SupportsRepeatandSupportsRepeatPeriod; fixesRemainingthrowing an invalid cast (the wrapper unboxed the mod'sKSPTimeSpanas adouble); guards members against use afterRemove; and makes alarm equality ID-based so the same alarm fetched twice compares equal.Triggeredreflects the mod's internal triggered state as a pollable getter, so clients can watch for it with expression events/streams rather than a bespoke event RPC.Tests. Adds a full create/round-trip/remove test suite covering every alarm property and alarm type, with a dedicated test craft, and wires the KerbalAlarmClock tests into
//:testand//:lintso they run as part of the standard suite.Testing. All 16 KerbalAlarmClock tests pass in-game against KerbalAlarmClock v3.14.0.0 on KSP 1.12.5.