Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add input validation command #1093

Merged
merged 5 commits into from
Jan 5, 2024
Merged

Add input validation command #1093

merged 5 commits into from
Jan 5, 2024

Conversation

kiritofeng
Copy link
Member

Add to init.yml

validator:
  source: validate.cpp
  language: CPP14
  time: 2
  memory: 65536

@codecov-commenter
Copy link

codecov-commenter commented Dec 31, 2022

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (e2b6533) 82.71% compared to head (73a2ade) 82.98%.
Report is 4 commits behind head on master.

Files Patch % Lines
dmoj/problem.py 81.48% 5 Missing ⚠️
dmoj/contrib/default.py 83.33% 2 Missing ⚠️
dmoj/contrib/testlib.py 77.77% 2 Missing ⚠️
dmoj/contrib/base.py 93.75% 1 Missing ⚠️
dmoj/contrib/coci.py 90.00% 1 Missing ⚠️
dmoj/contrib/peg.py 87.50% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1093      +/-   ##
==========================================
+ Coverage   82.71%   82.98%   +0.26%     
==========================================
  Files         141      143       +2     
  Lines        5310     5488     +178     
==========================================
+ Hits         4392     4554     +162     
- Misses        918      934      +16     

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

@kiritofeng kiritofeng force-pushed the validator branch 2 times, most recently from 3181c13 to 0b506a1 Compare December 31, 2022 23:10
@kiritofeng
Copy link
Member Author

kiritofeng commented Dec 31, 2022

Sample output:

dmoj> validate echo
Validating problem echo...
Batch #1
  Test case  1 AC
  Test case  2 IR (N != 1 in batch 1)
  Test case  3 IR (N not in (1, 2, 4))
  Test case  4 IR (N != 1 in batch 1)
Batch #2
  Test case  5 AC
  Test case  6 AC
  Test case  7 IR (N not in (1, 2, 4))
  Test case  8 AC
  Test case  9 IR (ValueError)
Problem echo failed.


Test complete.
A total of 1 problem(s) have invalid input

Validator:

import sys
batch = int(sys.argv[1])
N = int(input())
if N not in (1,2,4):
    print('N not in (1, 2, 4)')
    sys.exit(1)
elif N != 1 and batch == 1:
    print('N != 1 in batch 1')
    sys.exit(1)

init.yml:

test_cases:
- batched:
  - {in: 1.txt, out: 1.txt}
  - {in: 2.txt, out: 2.txt}
  - {in: 3.txt, out: 3.txt}
  - {in: 4.txt, out: 4.txt}
  points: 1
- batched:
  - {in: 1.txt, out: 1.txt}
  - {in: 2.txt, out: 2.txt}
  - {in: 3.txt, out: 3.txt}
  - {in: 4.txt, out: 4.txt}
  - {in: a.txt, out: a.txt}
  points: 1
validator:
  source: validate.py
  language: PY3
  time_limit: 2
  memory_limit: 65536
  read_feedback_from: stdout

(note that x.txt is a text file contain only x)

dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/contrib/coci.py Outdated Show resolved Hide resolved
dmoj/contrib/default.py Outdated Show resolved Hide resolved
dmoj/contrib/default.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
dmoj/commands/validate.py Outdated Show resolved Hide resolved
@kiritofeng kiritofeng force-pushed the validator branch 4 times, most recently from de7a41f to 67573db Compare December 31, 2023 18:56
Copy link
Member

@Xyene Xyene left a comment

Choose a reason for hiding this comment

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

LGTM

@Riolku
Copy link
Contributor

Riolku commented Jan 1, 2024

Yay for sanity - thanks for fixing it up.

@kiritofeng kiritofeng merged commit 9080d07 into master Jan 5, 2024
18 of 19 checks passed
@kiritofeng kiritofeng deleted the validator branch January 5, 2024 04:05
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.

5 participants