Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lask79 committed Feb 19, 2025
1 parent c05b464 commit 239ea12
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/test-antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,16 @@ jobs:
npm install --no-save @asciidoctor/core@~2.2
- name: Run Antora tests
env:
# Force CI mode and logging settings
CI: "true"
FORCE_COLOR: "1"
ANTORA_LOG_FORMAT: "json"
ANTORA_LOG_LEVEL: "all"
DEBUG: "antora:*"
run: |
# Make the test script executable
chmod +x tests/antora/run-antora.sh
# Run tests
npx jest tests/antora --verbose
# Run tests with CI-specific settings
npx jest tests/antora --verbose --no-colors
24 changes: 21 additions & 3 deletions tests/antora/antora-build.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,30 @@ describe('Antora Extension', () => {
const antoraOutput = output.split('=== Running Antora ===')[1]?.split('=== Antora Run Complete ===')[0] || '';
console.log('Antora specific output:', antoraOutput);

// Check for expected messages in the Antora-specific output
// Try to parse lines as JSON first
const jsonLines = antoraOutput.split('\n')
.map(line => {
try {
return JSON.parse(line.trim());
} catch (e) {
return null;
}
})
.filter(line => line !== null);

console.log('Parsed JSON lines:', jsonLines);

// Check for expected messages in both JSON and plain text
expectedMessages.forEach(msg => {
const found = antoraOutput.toLowerCase().includes(msg.toLowerCase());
expect(found).toBe(true,
const foundInJson = jsonLines.some(line =>
line.msg && line.msg.toLowerCase().includes(msg.toLowerCase())
);
const foundInPlainText = antoraOutput.toLowerCase().includes(msg.toLowerCase());

expect(foundInJson || foundInPlainText).toBe(true,
`Expected to find message: ${msg}\n` +
`In Antora output:\n${antoraOutput}\n` +
`Parsed JSON lines:\n${JSON.stringify(jsonLines, null, 2)}\n` +
`Full output:\n${output}`);
});
});
Expand Down
16 changes: 15 additions & 1 deletion tests/antora/run-antora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ echo "Playbook path: $1"
ls -l "$1"

echo "=== Running Antora ==="
npx antora --stacktrace --log-level=info "$1"

# In CI, we need to ensure output is not buffered
if [ "$CI" = "true" ]; then
# Run with unbuffered output and explicit logging
PYTHONUNBUFFERED=1 npx antora --stacktrace \
--log-level=all \
--log-format=json \
--fetch \
--to-dir=public \
--urls-preserve-trailing-slash \
"$1" 2>&1
else
# Regular local run
npx antora --stacktrace --log-level=info "$1"
fi

echo "=== Antora Run Complete ==="

0 comments on commit 239ea12

Please sign in to comment.