Skip to content

test: add regression tests for Live2D review blockers#350

Merged
yuh-yang merged 2 commits into
HKUDS:mainfrom
zyzly0705:live2d-regression-tests
Jun 14, 2026
Merged

test: add regression tests for Live2D review blockers#350
yuh-yang merged 2 commits into
HKUDS:mainfrom
zyzly0705:live2d-regression-tests

Conversation

@zyzly0705

Copy link
Copy Markdown
Contributor

Adds the regression tests requested in #313 review:

  • test_backup_clean_json_mode_deletes_files: Verifies actually deletes old backups (not just reports them)
  • test_flatten_copies_sound_assets: Verifies copies motion Sound audio files and rewrites references to flat paths
  • test_save_model_atomic: Verifies uses tempfile.mkstemp + os.replace for atomic writes
  • test_save_model_cleanup_on_error: Verifies temp files are cleaned up when write fails
  • test_auto_backup_skips_unchanged_content: Verifies deduplicates on content (filecmp), not wall-clock time
  • test_auto_backup_saves_changed_content: Verifies changed content always gets a new backup

All 20 tests pass (6 new + 14 existing).

- backup-clean --json actually deletes old backups
- flatten copies motion Sound assets
- save_model uses atomic write (tempfile + os.replace)
- auto_backup deduplicates on content, not wall-clock time
- save_model cleans up temp files on error
@github-actions github-actions Bot added the existing-cli-fix Fixes or improves an existing CLI harness label Jun 12, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9bf3a8fa1

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +266 to +269
# Simulate backup-clean --keep 2 (non-dry-run, non-json path deletes inline)
to_delete = backups[2:]
for f in to_delete:
f.unlink()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Exercise backup-clean instead of deleting manually

This test claims to cover backup-clean --json, but in the scenario where the JSON branch regresses back to reporting files without deleting them, it would still pass because the test deletes to_delete itself and never invokes the CLI with --json backup-clean --keep 2. That leaves the actual blocker untested; use CliRunner against the command and then assert only two backup files remain.

Useful? React with 👍 / 👎.

The previous test deleted files manually, which would pass even if the
CLI regressed. Now it invokes 'backup-clean --keep 2 --json' through
CliRunner and asserts both disk state and JSON output.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 71914884ea

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +291 to +293
# Same content -> should skip
result2 = auto_backup(sample_model3_file)
assert result2 is None

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Make unchanged-content test outlive throttle window

Because the second auto_backup() call happens immediately after the first one, an implementation that incorrectly skips backups only because the latest backup is younger than a time threshold would still pass this regression test for the wrong reason. To actually distinguish unchanged-content deduplication from age-based throttling, make the existing backup appear old enough (or patch the clock / sleep past the threshold) before calling auto_backup() with unchanged content.

Useful? React with 👍 / 👎.

Comment on lines +275 to +277
# Verify only 2 backups remain on disk
remaining = sorted(bdir.glob("*.model3.json"), reverse=True)
assert len(remaining) == 2, f"Expected 2 backups after cleanup, got {len(remaining)}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Assert backup-clean keeps the newest backups

This only checks that two backups remain, so a regression that sorts backups oldest-first before applying --keep 2 would delete the three newest backups and still pass with exactly two files left. Since the test creates five ordered backups, compare the remaining paths to the pre-clean backups[:2] or inspect the remaining JSON versions to verify that backup-clean kept the most recent backups, not just any two backups.

Useful? React with 👍 / 👎.

@yuh-yang yuh-yang merged commit 43f2981 into HKUDS:main Jun 14, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

existing-cli-fix Fixes or improves an existing CLI harness

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants