@@ -3,9 +3,9 @@ import * as exec from '@actions/exec'
33
44import * as fs from 'fs'
55import * as os from 'os'
6- import { expect , test } from '@jest/globals'
6+ import { expect , test } from '@jest/globals'
77
8- const osPlat = os . platform ( ) // possible values: win32 (Windows), linux (Linux), darwin (macOS)
8+ const osPlat = os . platform ( )
99
1010switch ( osPlat ) {
1111 case 'linux' :
@@ -19,6 +19,9 @@ switch (osPlat) {
1919}
2020commonTests ( )
2121
22+ /**
23+ * Uninstall OpenModelica on Linux system using apt-get purge.
24+ */
2225async function purgeOMC ( ) : Promise < void > {
2326 const fileContent = fs . readFileSync ( '/var/log/apt/history.log' ) . toString ( )
2427 const matches = fileContent . match ( 'Install: .*omc.*' )
@@ -33,6 +36,9 @@ async function purgeOMC(): Promise<void> {
3336 }
3437}
3538
39+ /**
40+ * Tests for Linux.
41+ */
3642function linuxTests ( ) : void {
3743 test ( 'Get Linux versions' , async ( ) => {
3844 const releaseVersions = installer . getOMVersions ( )
@@ -160,6 +166,9 @@ function linuxTests(): void {
160166 )
161167}
162168
169+ /**
170+ * Tests for Windows.
171+ */
163172function windowsTests ( ) : void {
164173 test (
165174 'Install 64 bit OpenModelica release 1.25.5' ,
@@ -170,16 +179,36 @@ function windowsTests(): void {
170179 const resVer = await installer . showVersion ( 'omc' )
171180 expect ( resVer ) . toContain ( '1.25.5' )
172181 } ,
173- 10 * 60000
182+ 60 * 60000
174183 )
175184}
176185
186+ /**
187+ * Test for Windows and Linux.
188+ */
177189function commonTests ( ) : void {
178190 test (
179191 'Install Modelica libraries' ,
180192 async ( ) => {
181- const libraries = [ 'Modelica 4.0.0' , 'Modelica 3.2.3+maint.om' ]
182- await installer . installLibs ( libraries )
193+ let output = ''
194+ const originalWrite = process . stdout . write
195+
196+ // Redirect stdout
197+ process . stdout . write = ( ( chunk : any ) => {
198+ output += chunk
199+ return true
200+ } ) as any
201+
202+ try {
203+ const libraries = [ 'Modelica 4.0.0' , 'NeuralNetwork 2.1.0' ]
204+ await installer . installLibs ( libraries )
205+
206+ expect ( output ) . toContain ( 'Installed: Modelica 4.0.0' )
207+ expect ( output ) . toContain ( 'Installed: NeuralNetwork 2.1.0' )
208+ } finally {
209+ // Restore original stdout
210+ process . stdout . write = originalWrite
211+ }
183212 } ,
184213 10 * 60000
185214 )
0 commit comments