Skip to content

feat: support case_batch_dependencies when using regex test case format - #1238

Open
Rishiii57 wants to merge 14 commits into
DMOJ:masterfrom
Rishiii57:fix/regex-case-batch-dependencies
Open

feat: support case_batch_dependencies when using regex test case format#1238
Rishiii57 wants to merge 14 commits into
DMOJ:masterfrom
Rishiii57:fix/regex-case-batch-dependencies

Conversation

@Rishiii57

Copy link
Copy Markdown
Contributor

Fixes #1232

Adds support for case_batch_dependencies when using regex test case format specifiers.

The key accepts an array of arrays, where each index corresponds to a batch:

test_cases:
case_batch_dependencies: [[], [1], [1], [], [1,2,3,4]]

Changes:

  • Added case_batch_dependencies parameter to _match_test_cases
  • Read and unwrap case_batch_dependencies from test_cases config node in _resolve_test_cases
  • Inject dependencies into batch dicts using array indexing

@dmoj-build

Copy link
Copy Markdown
Collaborator

Can one of the admins verify this patch?

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.58%. Comparing base (c59432f) to head (c753552).

Files with missing lines Patch % Lines
dmoj/problem.py 70.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1238      +/-   ##
==========================================
- Coverage   83.00%   82.58%   -0.43%     
==========================================
  Files         151      151              
  Lines        5732     5741       +9     
==========================================
- Hits         4758     4741      -17     
- Misses        974     1000      +26     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kiritofeng

Copy link
Copy Markdown
Member

Can you add a test for this to the testsuite? You can base it off of https://github.com/DMOJ/judge-server/blob/master/testsuite/batch_dependencies/init.yml.

@Rishiii57

Copy link
Copy Markdown
Contributor Author

Hey I've looked at the testsuite structure. Could you give me some guidance on how to add a regex-based test there? I'm on a Mac so I can't run the full judge environment locally to verify, since cptbox requires Linux.

@kiritofeng

kiritofeng commented Jun 4, 2026

Copy link
Copy Markdown
Member

You probably want to make {1,2,3,4}.txt (containing 1, 2, 3, 1) and then write init.yml

test_cases:
  input_format: (?P<case>\d)\.txt
  output_format: (?P<case>\d)\.txt
  case_batch_dependencies: [[], [], [1, 2], []]

and the rest can presumably be copied over without modification.

@Rishiii57

Copy link
Copy Markdown
Contributor Author

Yeah thats what I thought.
Done:)

@Rishiii57

Copy link
Copy Markdown
Contributor Author

Hey @kiritofeng I tried doing what you said but seems like some checks are failing. Could you please guide me what to do?

@kiritofeng

Copy link
Copy Markdown
Member

You also need to handle the case where the test case is not in a batch: https://github.com/DMOJ/judge-server/blob/master/dmoj/problem.py#L159

I also think that calling them case_dependencies instead of case_batch_dependencies might be a bit better

@Rishiii57

Copy link
Copy Markdown
Contributor Author

Hey @kiritofeng , I have updated the PR based on your suggestions :)
please have a look

@kiritofeng

Copy link
Copy Markdown
Member

The code is failing because the dependencies are not being correctly assigned; you should output the generated config and see why it's failing.

@kiritofeng

Copy link
Copy Markdown
Member

It's failing because the cases aren't being generated as batches but rather as individual test cases (and dependencies is literally batch_dependencies, i.e. it only works on batches), so you should probably rename it back to case_batch_dependencies and change the config so it generates batches instead of individual test cases.

@Rishiii57
Rishiii57 force-pushed the fix/regex-case-batch-dependencies branch from 647d5ac to 2245984 Compare June 14, 2026 06:08
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.

Allow batch dependencies when using regexes

3 participants