@@ -11,7 +11,7 @@ vi.mock("node:child_process", async () => {
1111 ) ;
1212} ) ;
1313
14- import { _resetCachedDarwinProductVersion , resolveOsSummary } from "./os-summary.js" ;
14+ import { resolveOsSummary , resolveRuntimeOsLabel } from "./os-summary.js" ;
1515
1616type OsSummaryCase = {
1717 name : string ;
@@ -25,7 +25,7 @@ type OsSummaryCase = {
2525describe ( "resolveOsSummary" , ( ) => {
2626 afterEach ( ( ) => {
2727 vi . restoreAllMocks ( ) ;
28- _resetCachedDarwinProductVersion ( ) ;
28+ spawnSyncMock . mockReset ( ) ;
2929 } ) ;
3030
3131 it . each < OsSummaryCase > ( [
@@ -96,3 +96,81 @@ describe("resolveOsSummary", () => {
9696 expect ( resolveOsSummary ( ) ) . toEqual ( expected ) ;
9797 } ) ;
9898} ) ;
99+
100+ describe ( "resolveRuntimeOsLabel" , ( ) => {
101+ afterEach ( ( ) => {
102+ vi . restoreAllMocks ( ) ;
103+ spawnSyncMock . mockReset ( ) ;
104+ } ) ;
105+
106+ it ( "reports the macOS product version without an architecture suffix on tahoe" , ( ) => {
107+ vi . spyOn ( os , "platform" ) . mockReturnValue ( "darwin" ) ;
108+ vi . spyOn ( os , "type" ) . mockReturnValue ( "Darwin" ) ;
109+ vi . spyOn ( os , "release" ) . mockReturnValue ( "25.6.0" ) ;
110+ vi . spyOn ( os , "arch" ) . mockReturnValue ( "arm64" ) ;
111+ spawnSyncMock . mockReturnValue ( {
112+ stdout : "26.6.0\n" ,
113+ stderr : "" ,
114+ pid : 1 ,
115+ output : [ ] ,
116+ status : 0 ,
117+ signal : null ,
118+ } ) ;
119+
120+ expect ( resolveRuntimeOsLabel ( ) ) . toBe ( "macOS 26.6.0" ) ;
121+ } ) ;
122+
123+ it ( "falls back to the Darwin release when sw_vers output is blank" , ( ) => {
124+ vi . spyOn ( os , "platform" ) . mockReturnValue ( "darwin" ) ;
125+ vi . spyOn ( os , "type" ) . mockReturnValue ( "Darwin" ) ;
126+ vi . spyOn ( os , "release" ) . mockReturnValue ( "25.7.0" ) ;
127+ vi . spyOn ( os , "arch" ) . mockReturnValue ( "arm64" ) ;
128+ spawnSyncMock . mockReturnValue ( {
129+ stdout : " " ,
130+ stderr : "" ,
131+ pid : 1 ,
132+ output : [ ] ,
133+ status : 0 ,
134+ signal : null ,
135+ } ) ;
136+
137+ expect ( resolveRuntimeOsLabel ( ) ) . toBe ( "macOS 25.7.0" ) ;
138+ } ) ;
139+
140+ it ( "preserves the old Windows os.type/os.release shape" , ( ) => {
141+ vi . spyOn ( os , "platform" ) . mockReturnValue ( "win32" ) ;
142+ vi . spyOn ( os , "type" ) . mockReturnValue ( "Windows_NT" ) ;
143+ vi . spyOn ( os , "release" ) . mockReturnValue ( "10.0.26100" ) ;
144+ vi . spyOn ( os , "arch" ) . mockReturnValue ( "x64" ) ;
145+
146+ expect ( resolveRuntimeOsLabel ( ) ) . toBe ( "Windows_NT 10.0.26100" ) ;
147+ } ) ;
148+
149+ it ( "preserves the old Linux os.type/os.release shape" , ( ) => {
150+ vi . spyOn ( os , "platform" ) . mockReturnValue ( "linux" ) ;
151+ vi . spyOn ( os , "type" ) . mockReturnValue ( "Linux" ) ;
152+ vi . spyOn ( os , "release" ) . mockReturnValue ( "6.8.0-generic" ) ;
153+ vi . spyOn ( os , "arch" ) . mockReturnValue ( "x64" ) ;
154+
155+ expect ( resolveRuntimeOsLabel ( ) ) . toBe ( "Linux 6.8.0-generic" ) ;
156+ } ) ;
157+
158+ it ( "caches the Darwin product version for repeated runtime prompt lookups" , ( ) => {
159+ vi . spyOn ( os , "platform" ) . mockReturnValue ( "darwin" ) ;
160+ vi . spyOn ( os , "type" ) . mockReturnValue ( "Darwin" ) ;
161+ vi . spyOn ( os , "release" ) . mockReturnValue ( "25.8.0" ) ;
162+ vi . spyOn ( os , "arch" ) . mockReturnValue ( "arm64" ) ;
163+ spawnSyncMock . mockReturnValue ( {
164+ stdout : "26.8.0\n" ,
165+ stderr : "" ,
166+ pid : 1 ,
167+ output : [ ] ,
168+ status : 0 ,
169+ signal : null ,
170+ } ) ;
171+
172+ expect ( resolveRuntimeOsLabel ( ) ) . toBe ( "macOS 26.8.0" ) ;
173+ expect ( resolveRuntimeOsLabel ( ) ) . toBe ( "macOS 26.8.0" ) ;
174+ expect ( spawnSyncMock ) . toHaveBeenCalledTimes ( 1 ) ;
175+ } ) ;
176+ } ) ;
0 commit comments