Skip to content

Commit 7020a50

Browse files
committed
trying project conditional tests
1 parent 12a63c8 commit 7020a50

File tree

4 files changed

+45
-12
lines changed

4 files changed

+45
-12
lines changed

.github/workflows/test.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,19 @@ jobs:
4646
for PROGRAM in sab dab; do
4747
echo "Processing projects for $PROGRAM"
4848
mkdir -p "$HOME/projects/$PROGRAM"
49-
PROJECTS=$(jq -r ".${PROGRAM}.projects[]" "test_data/projects/index.json")
50-
for PROJECT_ZIP in $PROJECTS; do
49+
50+
# Get all projects as JSON array
51+
PROJECTS_JSON=$(jq -r ".${PROGRAM}.projects" "test_data/projects/index.json")
52+
53+
# Get number of projects
54+
NUM_PROJECTS=$(echo "$PROJECTS_JSON" | jq '. | length')
55+
56+
# Iterate through projects using index
57+
for ((i=0; i<$NUM_PROJECTS; i++)); do
58+
# Get project path and test directories
59+
PROJECT_ZIP=$(echo "$PROJECTS_JSON" | jq -r ".[$i].path")
60+
TEST_DIRS=$(echo "$PROJECTS_JSON" | jq -r ".[$i].tests[]")
61+
5162
PROJECT_NAME=$(basename "$PROJECT_ZIP" .zip)
5263
echo "Project: $PROJECT_NAME"
5364
PROJECT_DIR="$HOME/projects/${PROGRAM}/$PROJECT_NAME"
@@ -60,6 +71,11 @@ jobs:
6071
popd > /dev/null
6172
npm run build
6273
npm run convert
63-
npm run test
74+
75+
# Run tests for each specified directory
76+
for TEST_DIR in $TEST_DIRS; do
77+
echo "Running tests in directory: $TEST_DIR"
78+
npm run test "$TEST_DIR"
79+
done
6480
done
65-
done
81+
done

src/lib/scripts/convertConfigDAB.test.ts renamed to convert/tests/convertConfigDAB.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import path from 'path';
33
import type { DictionaryConfig, DictionaryWritingSystemConfig } from '$config';
44
import jsdom from 'jsdom';
55
import { expect, test } from 'vitest';
6-
import { parseDictionaryWritingSystem, parseFeatures } from '../../../convert/convertConfig';
6+
import { parseDictionaryWritingSystem, parseFeatures } from '../convertConfig';
77

88
const dataDir = './data/';
99
const dom = new jsdom.JSDOM(readFileSync(path.join(dataDir, 'appdef.xml')).toString(), {

src/lib/scripts/convertConfigSAB.test.ts renamed to convert/tests/convertConfigSAB.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import {
2222
parseTraits,
2323
parseVideos,
2424
parseWatermarkImages
25-
} from '../../../convert/convertConfig';
25+
} from '../convertConfig';
2626

2727
const dataDir = './data/';
2828
const dom = new jsdom.JSDOM(readFileSync(path.join(dataDir, 'appdef.xml')).toString(), {

test_data/projects/index.json

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
{
2-
"sab" : {
3-
"projects" : [
4-
"web_gospels.zip",
5-
"sab_pwa_test.zip"
2+
"sab": {
3+
"projects": [
4+
{
5+
"tests": [
6+
"src/",
7+
"convert/"
8+
],
9+
"path": "web_gospels.zip"
10+
},
11+
{
12+
"tests": [
13+
"src/"
14+
],
15+
"path": "sab_pwa_test.zip"
16+
}
617
]
718
},
819
"dab": {
9-
"projects" : [
10-
"hanga.zip"
20+
"projects": [
21+
{
22+
"tests": [
23+
"src/",
24+
"convert/"
25+
],
26+
"path": "hanga.zip"
27+
}
1128
]
1229
}
1330
}

0 commit comments

Comments
 (0)