Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
maspypy committed Sep 15, 2023
2 parents 3fbfcf2 + 6c96294 commit 6c00796
Show file tree
Hide file tree
Showing 23 changed files with 9 additions and 703 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,7 @@ jobs:
- name: Run generate.py on gcc
run: |
ulimit -s unlimited
./ci_generate.py --htmldir=/tmp/html
- name: Archive problem statements
uses: actions/upload-artifact@v2
with:
name: statements
path: /tmp/html
./ci_generate.py
mingw-windows-diffrun:
runs-on: windows-latest
Expand Down Expand Up @@ -119,4 +114,4 @@ jobs:
- name: Run generate.py on gcc
run: |
python ci_generate.py --htmldir=D:/tmp/html
python ci_generate.py
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Source code of [https://judge.yosupo.jp](https://judge.yosupo.jp). You can get t
cd /path/to/library-checker-problems

pip3 install -r requirements.txt
# or pip3 install colorlog markdown jinja2
# or pip3 install colorlog

ulimit -s unlimited # for linux (doesn't need for OS X and WSL)

Expand All @@ -36,7 +36,6 @@ file datastructure/unionfind/checker # binary of output checker
```sh
./generate.py -p unionfind --dev # developer mode
./generate.py -p unionfind --test # test mode (for developer, exec this command before PR)
cat datastructure/unionfind/task.html # statement

./generate.py $(find . -name "info.toml" -not -path "./test/*") # generate all testcases
```
Expand Down
8 changes: 2 additions & 6 deletions ci_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def main():
parser = argparse.ArgumentParser(
description='Testcase generator')
parser.add_argument('--print-version', action='store_true', help='Print version')
parser.add_argument('--htmldir', help='Generate HTML', default=None)
args = parser.parse_args()

basicConfig(
Expand Down Expand Up @@ -47,9 +46,6 @@ def main():
cache = cache_dir / 'generated.json'
generated = json.load(open(str(cache))) if cache.exists() else dict()

if args.htmldir:
Path(args.htmldir).mkdir(exist_ok=True, parents=True)

for x in tomls:
problem = Problem(Path.cwd(), x.parent)
problem_name = problem.basedir.name
Expand All @@ -58,8 +54,8 @@ def main():
logger.info('Problem {} is already generated, skip'.format(problem_name))
else:
logger.info('Generate {}, new version: {}'.format(problem_name, problem_version))
problem.generate(mode=Problem.Mode.TEST, html_dir=Path(args.htmldir) if args.htmldir else None)
problem.generate(mode=Problem.Mode.CLEAN, html_dir=None)
problem.generate(mode=Problem.Mode.TEST)
problem.generate(mode=Problem.Mode.CLEAN)
if problem_name not in generated:
generated[problem_name] = dict()

Expand Down
14 changes: 3 additions & 11 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,14 @@ def main(args: List[str]):

parser.add_argument('--dev', action='store_true', help='Developer Mode')
parser.add_argument('--test', action='store_true', help='CI Mode')
parser.add_argument('--htmldir', help='Generate HTML', default=None)
parser.add_argument('--clean', action='store_true', help='Clean in/out')
parser.add_argument('--compile-checker',
action='store_true', help='Deprecated: Compile Checker')
parser.add_argument('--only-html', action='store_true', help='HTML generator Mode')

opts = parser.parse_args(args)

if opts.dev + opts.test + opts.clean + opts.only_html >= 2:
raise ValueError('at most one of --dev, --test, --clean, --only-html can be used')
if opts.dev + opts.test + opts.clean >= 2:
raise ValueError('at most one of --dev, --test, --clean can be used')

if opts.compile_checker:
logger.warning(
Expand All @@ -87,10 +85,6 @@ def main(args: List[str]):

if len(problems) == 0:
logger.warning('No problems')

if opts.htmldir:
logger.info('Make htmldir')
Path(opts.htmldir).mkdir(exist_ok=True, parents=True)

# suppress the annoying dialog appears when an application crashes on Windows
if platform.uname().system == 'Windows':
Expand All @@ -105,11 +99,9 @@ def main(args: List[str]):
mode = Problem.Mode.TEST
if opts.clean:
mode = Problem.Mode.CLEAN
if opts.only_html:
mode = Problem.Mode.HTML

for problem in problems:
problem.generate(mode, Path(opts.htmldir) if opts.htmldir else None)
problem.generate(mode)

if __name__ == '__main__':
main(sys.argv[1:])
80 changes: 0 additions & 80 deletions generate_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,47 +115,6 @@ def test_non_exist_problem(self):
['./generate.py', '-p', 'dummy_problem'])
self.assertNotEqual(proc.returncode, 0)


class TestUnusedExample(unittest.TestCase):
def test_unused_example_user(self):
with create_test_dir('unused_example') as test_dir:
proc = run(
['./generate.py', str(Path(test_dir) / 'unused_example/info.toml')])
self.assertEqual(proc.returncode, 0)

def test_unused_example_dev(self):
with create_test_dir('unused_example') as test_dir:
proc = run(['./generate.py', str(Path(test_dir) /
'unused_example/info.toml'), '--dev'])
self.assertEqual(proc.returncode, 0)

def test_unused_example_test(self):
with create_test_dir('unused_example') as test_dir:
proc = run(['./generate.py', str(Path(test_dir) /
'unused_example/info.toml'), '--test'])
self.assertNotEqual(proc.returncode, 0)


class TestNonExistExample(unittest.TestCase):
def test_no_html(self):
with create_test_dir('nonexist_example') as test_dir:
proc = run(
['./generate.py', str(Path(test_dir) / 'nonexist_example/info.toml')])
self.assertEqual(proc.returncode, 0)

def test_non_exist_dev(self):
with create_test_dir('nonexist_example') as test_dir:
proc = run(['./generate.py', str(Path(test_dir) /
'nonexist_example/info.toml'), '--dev'])
self.assertNotEqual(proc.returncode, 0)

def test_non_exist_test(self):
with create_test_dir('nonexist_example') as test_dir:
proc = run(['./generate.py', str(Path(test_dir) /
'nonexist_example/info.toml'), '--test'])
self.assertNotEqual(proc.returncode, 0)


class TestUnusedGen(unittest.TestCase):
def test_unused_gen_user(self):
with create_test_dir('unused_gen') as test_dir:
Expand Down Expand Up @@ -276,45 +235,6 @@ def test_list_depending_files(self):
self.assertTrue(find_random)
self.assertTrue(find_verifier)


class TestGenerateHtml(unittest.TestCase):
def test_generate_html_dev(self):
with create_test_dir('simple_aplusb') as test_dir:
proc = run(['./generate.py', str(Path(test_dir) /
'simple_aplusb/info.toml'), '--dev'])
self.assertEqual(proc.returncode, 0)
self.assertTrue(
(Path(test_dir) / 'simple_aplusb' / 'task.html').exists())

def test_generate_html_test(self):
with create_test_dir('simple_aplusb') as test_dir:
proc = run(['./generate.py', str(Path(test_dir) /
'simple_aplusb/info.toml'), '--test'])
self.assertEqual(proc.returncode, 0)
self.assertTrue(
(Path(test_dir) / 'simple_aplusb' / 'task.html').exists())


class TestHtmlDir(unittest.TestCase):
def test_generate_html_dev(self):
with create_test_dir('simple_aplusb') as test_dir:
html_dir = TemporaryDirectory()
proc = run(['./generate.py', str(Path(test_dir) /
'simple_aplusb/info.toml'), '--dev', '--htmldir', html_dir.name])
self.assertEqual(proc.returncode, 0)
self.assertTrue(
(Path(html_dir.name) / 'simple_aplusb.html').exists())

def test_generate_html_test(self):
with create_test_dir('simple_aplusb') as test_dir:
html_dir = TemporaryDirectory()
proc = run(['./generate.py', str(Path(test_dir) /
'simple_aplusb/info.toml'), '--test', '--htmldir', html_dir.name])
self.assertEqual(proc.returncode, 0)
self.assertTrue(
(Path(html_dir.name) / 'simple_aplusb.html').exists())


if __name__ == "__main__":
basicConfig(
level=getenv('LOG_LEVEL', 'DEBUG'),
Expand Down
Loading

0 comments on commit 6c00796

Please sign in to comment.