diff --git a/exobrain/src/check.py b/exobrain/src/check.py index 2c6075e..21e692b 100755 --- a/exobrain/src/check.py +++ b/exobrain/src/check.py @@ -1,9 +1,13 @@ #!/usr/bin/env python3 +import os from pathlib import Path from subprocess import run from typing import Iterator, List +import orgparse + + class Failed(RuntimeError): pass @@ -22,12 +26,14 @@ def search(*args): yield Failed(res) -import orgparse # type: ignore - -from checks import F_CHECKS, WORD_CHECKS, TAG_CHECKS - - def check(path: Path) -> Iterator[Failed]: + if 'CI' not in os.environ: + from checks import F_CHECKS, WORD_CHECKS, TAG_CHECKS + else: + F_CHECKS = [] + WORD_CHECKS = [] + TAG_CHECKS = set() + print(f"checking {path}") for x in F_CHECKS: yield from search( diff --git a/exobrain/src/test.py b/exobrain/src/test.py index 1d94edd..90ffc45 100644 --- a/exobrain/src/test.py +++ b/exobrain/src/test.py @@ -1,3 +1,4 @@ +import os from pathlib import Path from subprocess import run, check_call, check_output, Popen, PIPE, CalledProcessError from time import sleep @@ -10,6 +11,9 @@ from utils import tmp_popen +on_ci = 'CI' in os.environ + + def build(*args): return ['src/build.py', *args] @@ -33,8 +37,17 @@ def tmp_data(tmp_path: Path): yield td -def test_build_empty(tmp_data: Path) -> None: - check_call(build('--data-dir', tmp_data)) +@pytest.mark.parametrize('use_new_org_export' , [True, False], ids=['org_new' , 'org_old']) +@pytest.mark.parametrize('use_new_html_export', [True, False], ids=['html_new', 'html_old']) +def test_build_empty(use_new_org_export: bool, use_new_html_export: bool, tmp_data: Path) -> None: + if on_ci: + if not use_new_html_export: + pytest.skip("doesn't work on ci yet") + if not use_new_org_export: + pytest.skip("doesn't work on ci yet") + oargs = ['--use-new-org-export'] if use_new_org_export else [] + hargs = ['--use-new-html-export'] if use_new_html_export else [] + check_call(build('--data-dir', tmp_data, *oargs, *hargs)) def _check_org(path: Path) -> None: @@ -45,6 +58,11 @@ def _check_org(path: Path) -> None: @pytest.mark.parametrize('use_new_org_export' , [True, False], ids=['org_new' , 'org_old']) @pytest.mark.parametrize('use_new_html_export', [True, False], ids=['html_new', 'html_old']) def test_test(use_new_org_export: bool, use_new_html_export: bool, tmp_data: Path, tmp_path: Path) -> None: + if on_ci: + if not use_new_html_export: + pytest.skip("doesn't work on ci yet") + if not use_new_org_export: + pytest.skip("doesn't work on ci yet") d = tmp_data i = d / 'input' public = d / 'public' @@ -101,8 +119,23 @@ def test_test(use_new_org_export: bool, use_new_html_export: bool, tmp_data: Pat assert 'more tag inheritance tag1tag2tag_atag_btag_c' in test_html -def test_build_some(tmp_data: Path, tmp_path: Path) -> None: +@pytest.mark.parametrize('use_new_org_export' , [True, False], ids=['org_new' , 'org_old']) +@pytest.mark.parametrize('use_new_html_export', [True, False], ids=['html_new', 'html_old']) +def test_build_some(use_new_org_export: bool, use_new_html_export: bool, tmp_data: Path, tmp_path: Path) -> None: + if on_ci: + if not use_new_html_export: + pytest.skip("doesn't work on ci yet") + if not use_new_org_export: + pytest.skip("doesn't work on ci yet") + d = tmp_data + + def run_build(*args): + oargs = ['--use-new-org-export'] if use_new_org_export else [] + hargs = ['--use-new-html-export'] if use_new_html_export else [] + check_call(build('--data-dir', d, *oargs, *hargs, *args)) + + i = d / 'input' public = d / 'public' html = d / 'html' @@ -117,7 +150,7 @@ def test_build_some(tmp_data: Path, tmp_path: Path) -> None: copy(INPUT / 'projects/cachew.org', cachew) # TODO add another one? - check_call(build('--data-dir', d)) + run_build() _check_org(public / 'projects/cachew.org') # _check_org(public / 'memex.org') @@ -153,11 +186,11 @@ def diff() -> List[str]: return l1 + l2 # NOTE: if we don't clean properly, documents.js ends with entries from TOC.. ugh - check_call(build('--data-dir', d)) + run_build() assert diff() == [] ## - # FIXME watch mode is broken for now + # FIXME watch mode is broken for now due to sitemap return with tmp_popen(build('--data-dir', d, '--watch')) as popen: