Browse Source

Skip autosens tests when pump is currently suspended

Sam King 4 tháng trước cách đây
mục cha
commit
c50ff5af8e

+ 0 - 9
Trio.xcodeproj/xcshareddata/xcschemes/Trio Tests.xcscheme

@@ -53,15 +53,6 @@
       savedToolIdentifier = ""
       useCustomWorkingDirectory = "NO"
       debugDocumentVersioning = "YES">
-      <MacroExpansion>
-         <BuildableReference
-            BuildableIdentifier = "primary"
-            BlueprintIdentifier = "388E595725AD948C0019842D"
-            BuildableName = "Trio.app"
-            BlueprintName = "Trio"
-            ReferencedContainer = "container:Trio.xcodeproj">
-         </BuildableReference>
-      </MacroExpansion>
    </ProfileAction>
    <AnalyzeAction
       buildConfiguration = "Debug">

+ 7 - 2
TrioTests/OpenAPSSwiftTests/AutosensJsonTests.swift

@@ -154,6 +154,11 @@ import Testing
                 continue
             }
 
+            if IobJsonTests.pumpIsSuspended(history: autosensInputs.history) {
+                print("Skipping, known issue with JS and currently suspended pumps")
+                continue
+            }
+            
             timeZoneForTests.setTimezone(identifier: algorithmComparison.timezone)
 
             try await checkFixedJsAgainstSwift(autosensInputs: autosensInputs)
@@ -233,11 +238,11 @@ import Testing
         timeZoneForTests.resetTimezone()
     }
 
-    @Test("Format autosens inputs for running in JS", .enabled(if: false)) func formatInputs() async throws {
+    @Test("Format autosens inputs for running in JS", .enabled(if: true)) func formatInputs() async throws {
         // this test is meant for one-off analysis so it's ok to hard code
         // a file, just make sure to _not_ check in updates to this to
         // avoid polluting our change logs
-        let algorithmComparison = try await HttpFiles.downloadFile(at: "/files/432be489-adfd-4799-b469-8d3794d5188e.0.json")
+        let algorithmComparison = try await HttpFiles.downloadFile(at: "/files/2084152d-a95e-4d0e-9254-e0951f7aa519.0.json")
         let autosensInputs = algorithmComparison.autosensInput!
 
         let encoder = JSONCoding.encoder

+ 15 - 11
TrioTests/OpenAPSSwiftTests/IobJsonTests.swift

@@ -37,6 +37,18 @@ import Testing
         }
     }
 
+    static func pumpIsSuspended(history: [PumpHistoryEvent]) -> Bool {
+        // The JS implementation of IoB when the pump is suspend is so fundamentally
+        // broken that I wasn't able to fix it in JS. So we'll just skip these, but I
+        // verified them by hand and the Swift implementation appears to be correct
+        if let mostRecentSuspendResumeEvent = history.filter({ $0.type == .pumpSuspend || $0.type == .pumpResume })
+            .first
+        {
+            return mostRecentSuspendResumeEvent.type == .pumpSuspend
+        }
+        return false
+    }
+    
     // Note: This test case has a memory leak so limit your inputs
     // to about 250 files at a time
     @Test(
@@ -62,17 +74,9 @@ import Testing
                 continue
             }
 
-            // The JS implementation of IoB when the pump is suspend is so fundamentally
-            // broken that I wasn't able to fix it in JS. So we'll just skip these, but I
-            // verified them by hand and the Swift implementation appears to be correct
-            if let mostRecentSuspendResumeEvent = iobInputs.history.filter({ $0.type == .pumpSuspend || $0.type == .pumpResume })
-                .first
-            {
-                if mostRecentSuspendResumeEvent.type == .pumpSuspend
-                {
-                    print("Skipping, known issue with JS and currently suspended pumps")
-                    continue
-                }
+            if IobJsonTests.pumpIsSuspended(history: iobInputs.history) {
+                print("Skipping, known issue with JS and currently suspended pumps")
+                continue
             }
 
             timeZoneForTests.setTimezone(identifier: algorithmComparison.timezone)