Skip to content

Commit 5b6e030

Browse files
authored
Test lib installation (#449)
1 parent 2c25685 commit 5b6e030

File tree

2 files changed

+56
-12
lines changed

2 files changed

+56
-12
lines changed

.github/workflows/test.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: 'build-test'
2-
on: # rebuild any PRs and main branch changes
2+
on:
33
pull_request:
44
push:
55
branches:
@@ -9,24 +9,39 @@ on: # rebuild any PRs and main branch changes
99
types: [dependabot-dist-updated]
1010

1111
jobs:
12-
build: # make sure build/ci work properly
13-
runs-on: ubuntu-latest
12+
build: # make sure build/ci works properly
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest, windows-latest]
16+
runs-on: ${{ matrix.os }}
17+
1418
steps:
1519
- uses: actions/checkout@v5
20+
1621
- name: Set Node.js 20.x
1722
uses: actions/setup-node@v6
1823
with:
1924
node-version: 20.x
20-
- run: |
21-
npm install
22-
- run: |
23-
npm run all
25+
26+
- name: Install
27+
run: npm install
28+
29+
- name: Build
30+
run: npm run build
31+
32+
- name: Package
33+
run: npm run package
34+
35+
- name: Jest Test
36+
run: npm run test
37+
2438
test: # make sure the action works on a clean machine without building
2539
strategy:
2640
matrix:
2741
os: [ubuntu-latest, windows-latest]
2842
version: [stable, '1.25']
2943
runs-on: ${{ matrix.os }}
44+
3045
steps:
3146
- uses: actions/checkout@v5
3247

__tests__/installer.test.ts

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import * as exec from '@actions/exec'
33

44
import * as fs from 'fs'
55
import * 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

1010
switch (osPlat) {
1111
case 'linux':
@@ -19,6 +19,9 @@ switch (osPlat) {
1919
}
2020
commonTests()
2121

22+
/**
23+
* Uninstall OpenModelica on Linux system using apt-get purge.
24+
*/
2225
async 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+
*/
3642
function 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+
*/
163172
function 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+
*/
177189
function 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

Comments
 (0)