Skip to content

TEST add unit tests for build scripts#1642

Merged
romanlutz merged 4 commits intomicrosoft:mainfrom
tejas0077:maint/build-script-tests-clean
Apr 30, 2026
Merged

TEST add unit tests for build scripts#1642
romanlutz merged 4 commits intomicrosoft:mainfrom
tejas0077:maint/build-script-tests-clean

Conversation

@tejas0077
Copy link
Copy Markdown
Contributor

Closes #1570

Adds unit tests for 4 build scripts as requested by @romanlutz in #1569.

  • test_prepare_package.py — 9 tests covering npm lookup, install/build failures, and frontend copy logic
  • test_validate_docs.py — 14 tests covering TOC parsing, missing file detection, and orphaned file checks
  • test_generate_rss.py — 10 tests covering date extraction and blog markdown parsing
  • test_check_links.py — 13 tests covering URL extraction, fragment stripping, and relative URL resolution

Added 46 unit tests across 4 new test files.
All 65 tests in tests/unit/build_scripts/ pass locally:

python -m pytest tests/unit/build_scripts/ -v

65 passed

No documentation changes required.
No JupyText changes required.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds unit tests under tests/unit/build_scripts/ to cover several Python build/validation scripts, improving reliability across platforms and catching regressions in packaging/docs/link-check tooling.

Changes:

  • Added unit tests for validate_docs TOC parsing / missing-file validation / orphan detection.
  • Added unit tests for prepare_package frontend build and packaging copy behavior.
  • Added unit tests for generate_rss date extraction and blog markdown parsing, plus check_links URL extraction and resolution helpers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

File Description
tests/unit/build_scripts/test_prepare_package.py Tests frontend build failure/success paths and frontend dist copy behavior.
tests/unit/build_scripts/test_validate_docs.py Tests TOC parsing, referenced-file validation, and orphaned doc detection.
tests/unit/build_scripts/test_generate_rss.py Tests filename date parsing and blog markdown parsing helpers.
tests/unit/build_scripts/test_check_links.py Tests URL extraction, fragment stripping, and relative URL resolution.

Comment thread tests/unit/build_scripts/test_prepare_package.py Outdated
Comment thread tests/unit/build_scripts/test_prepare_package.py Outdated
Comment thread tests/unit/build_scripts/test_prepare_package.py Outdated
Comment thread tests/unit/build_scripts/test_validate_docs.py Outdated
Comment thread tests/unit/build_scripts/test_check_links.py Outdated
Comment thread tests/unit/build_scripts/test_generate_rss.py Outdated
Comment thread tests/unit/build_scripts/test_generate_rss.py Outdated
Comment thread tests/unit/build_scripts/test_prepare_package.py Outdated
Tejas Saubhage and others added 2 commits April 23, 2026 03:28
- Refactor generate_rss.py: wrap side effects under if __name__ == '__main__'
  so the module is cleanly importable without AST exec() workaround
- Replace fragile AST exec() loader in test_generate_rss.py with direct import
- Convert all test classes to standalone functions per test conventions
- Fix test_build_frontend_returns_true_when_build_succeeds: use side_effect
  with 3 explicit responses and verify call_count == 3
- Strengthen weak assertion in test_resolve_relative_url_resolved to check
  exact path instead of loose substring match
- Remove unused imports (tempfile, pytest)

Co-authored-by: Copilot <[email protected]>
Copy link
Copy Markdown
Contributor

@romanlutz romanlutz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll just push my changes directly.

@romanlutz romanlutz changed the title add unit tests for build scripts TEST add unit tests for build scripts Apr 30, 2026
@romanlutz romanlutz enabled auto-merge April 30, 2026 14:22
@romanlutz romanlutz added this pull request to the merge queue Apr 30, 2026
Merged via the queue into microsoft:main with commit 063ae4f Apr 30, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MAINT add tests for build scripts

4 participants