diff --git a/.coverage b/.coverage index 9210b7f..836b9d2 100644 Binary files a/.coverage and b/.coverage differ diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml old mode 100644 new mode 100755 index e4dd940..1fef291 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -16,12 +16,36 @@ jobs: DTC_HEADLES: true steps: - uses: actions/checkout@v3 + + # Set up Python + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + cache: 'pip' + + # Install dependencies + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e ".[test]" # Install package with test dependencies + pip install pytest-html # Install additional test dependencies + pip install pytest pytest-cov + + # Setup and generate site - name: setup run: chmod +x dtcw - name: generateSite run: ./dtcw generateSite + + # Run tests and generate reports + - name: Run tests with coverage + run: python run_tests_html.py + - name: copyToPublic run: cp -r ./build/microsite/output ./public + + # Deploy - name: Deploy uses: peaceiris/actions-gh-pages@v3 # if: ${{ github.ref == 'refs/heads/main' }} diff --git a/.github/workflows/gh-pages.yml.meta b/.github/workflows/gh-pages.yml.meta new file mode 100644 index 0000000..9e6b2fe --- /dev/null +++ b/.github/workflows/gh-pages.yml.meta @@ -0,0 +1 @@ +GitHub Actions workflow for running tests and deploying to GitHub Pages \ No newline at end of file diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore index 242a3b2..5f98d9d 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,8 @@ dist/* # ignore all files in the .idea directory .idea/* -.gradle/* \ No newline at end of file +.gradle/* + +venv/* + +.coverage \ No newline at end of file diff --git a/coverage.xml b/coverage.xml index d704102..b68370b 100644 --- a/coverage.xml +++ b/coverage.xml @@ -1,12 +1,12 @@ - + /mount/files/8af0cd603d83f27b02be74a4ac996dbc3b768025787c885e978faef4c49f4a8d/home/sandboxuser/asciidoc-linter/asciidoc_linter - + @@ -61,96 +61,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -275,7 +185,7 @@ - + @@ -288,7 +198,7 @@ - + @@ -299,62 +209,73 @@ + - - - - - + + + + - + - + + + - - + + + - - - + + - - + - + + + + + + + + + + + - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + @@ -365,115 +286,142 @@ - - - + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - + + + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - + - - - + - - - - - - - - - - + + + + + + + + - - - + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -487,66 +435,72 @@ + - - - + + + - - + - - - - - - - + - - - - - - + + - + - - - - - + + + + + + + + + + - + + + + + + + - - + + + + + + + + + - - + + + + - + - + - - + + - - - - - + @@ -557,40 +511,42 @@ - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/debug_env.py b/debug_env.py new file mode 100644 index 0000000..8d32816 --- /dev/null +++ b/debug_env.py @@ -0,0 +1,38 @@ +# debug_env.py - Environment debugging script +import sys +import subprocess +import pkg_resources + +def print_section(title): + print("\n" + "="*50) + print(title) + print("="*50) + +def run_command(cmd): + try: + result = subprocess.run(cmd, capture_output=True, text=True) + print(f"Command: {' '.join(cmd)}") + print("Output:") + print(result.stdout) + if result.stderr: + print("Errors:") + print(result.stderr) + except Exception as e: + print(f"Error running command: {e}") + +print_section("Python Information") +print(f"Python Version: {sys.version}") +print(f"Python Executable: {sys.executable}") + +print_section("Installed Packages") +installed_packages = [f"{dist.key} {dist.version}" for dist in pkg_resources.working_set] +print("\n".join(sorted(installed_packages))) + +print_section("Pytest Version Check") +run_command([sys.executable, "-m", "pytest", "--version"]) + +print_section("Coverage Installation Check") +run_command([sys.executable, "-m", "pip", "list", "|", "grep", "coverage"]) + +print_section("Pytest Plugins") +run_command([sys.executable, "-m", "pytest", "--trace-config"]) \ No newline at end of file diff --git a/debug_env.py.meta b/debug_env.py.meta new file mode 100644 index 0000000..26558d0 --- /dev/null +++ b/debug_env.py.meta @@ -0,0 +1 @@ +Script to debug the Python environment \ No newline at end of file diff --git a/docs/test-results/01-unit-tests.adoc b/docs/test-results/01-unit-tests.adoc new file mode 100644 index 0000000..efacfb7 --- /dev/null +++ b/docs/test-results/01-unit-tests.adoc @@ -0,0 +1,5 @@ +:jbake-title: Unit Tests + +++++ + +++++ diff --git a/docs/test-results/02-coverage.adoc b/docs/test-results/02-coverage.adoc new file mode 100644 index 0000000..2496ff9 --- /dev/null +++ b/docs/test-results/02-coverage.adoc @@ -0,0 +1,5 @@ +:jbake-title: Coverage + +++++ + +++++ diff --git a/pyproject.toml b/pyproject.toml index 191a69f..a38c145 100755 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,6 @@ test = [ ] [tool.pytest.ini_options] -addopts = "--cov=asciidoc_linter --cov-report=xml --cov-report=term-missing" testpaths = ["tests"] [project.scripts] diff --git a/pyproject.toml.meta b/pyproject.toml.meta index a7deda5..03916ef 100755 --- a/pyproject.toml.meta +++ b/pyproject.toml.meta @@ -1 +1 @@ -Project configuration file containing build system requirements and project metadata \ No newline at end of file +Project configuration file without pytest coverage settings \ No newline at end of file diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..d40604b --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +addopts = --cov=asciidoc_linter --cov-report=html --cov-report=term-missing -v +testpaths = tests \ No newline at end of file diff --git a/pytest.ini.meta b/pytest.ini.meta new file mode 100644 index 0000000..41117cb --- /dev/null +++ b/pytest.ini.meta @@ -0,0 +1 @@ +Pytest configuration file \ No newline at end of file diff --git a/run_tests_html.py b/run_tests_html.py new file mode 100755 index 0000000..d69744a --- /dev/null +++ b/run_tests_html.py @@ -0,0 +1,89 @@ +# run_tests_html.py - Test runner script with HTML report +""" +Script to run all tests for the AsciiDoc linter and generate HTML reports +Requires: pytest-html, pytest-cov (install with: pip install pytest-html pytest-cov) +""" + +import subprocess +import sys +import shutil +from pathlib import Path +from datetime import datetime + +def ensure_dir_exists(path: Path): + """Create directory if it doesn't exist""" + path.mkdir(parents=True, exist_ok=True) + +def copy_reports(temp_test_report: Path, docs_dir: Path): + """Copy reports to docs directory""" + ensure_dir_exists(docs_dir) + + # Define target files + final_test_report = docs_dir / 'test-report.html' + final_cov_dir = docs_dir / 'coverage' + + # Remove old coverage directory if it exists + if final_cov_dir.exists(): + shutil.rmtree(final_cov_dir) + + # Copy new reports + shutil.copy2(temp_test_report, final_test_report) + + # Copy coverage report if it exists + temp_cov = Path('htmlcov') + if temp_cov.exists(): + shutil.copytree(temp_cov, final_cov_dir) + shutil.rmtree(temp_cov) # Clean up temporary coverage directory + + return final_test_report, final_cov_dir + +if __name__ == '__main__': + print("Starting test execution...") + + # Create reports directory + reports_dir = Path('test-reports') + print(f"Creating reports directory: {reports_dir}") + ensure_dir_exists(reports_dir) + + # Generate timestamp for unique report name + timestamp = datetime.now().strftime('%Y%m%d_%H%M%S') + test_report = reports_dir / f'test_report_{timestamp}.html' + + # Construct pytest command with only HTML report arguments + cmd = [ + sys.executable, + '-m', + 'pytest', + f'--html={test_report}', + '--self-contained-html' + ] + + print(f"Executing command: {' '.join(cmd)}") + + # Run pytest as a subprocess + try: + result = subprocess.run(cmd, check=False) + + # If tests were successful, copy reports to docs + if result.returncode == 0: + try: + docs_dir = Path('build/microsite/output/test-results') + final_test, final_cov = copy_reports(test_report, docs_dir) + print(f"\nReports copied to docs:") + print(f"Test report: {final_test}") + print(f"Coverage report: {final_cov}/index.html") + except Exception as e: + print(f"\nError copying reports: {e}") + sys.exit(1) + else: + print("\nTests failed - reports were generated but not copied to docs") + + # Clean up temporary reports + shutil.rmtree(reports_dir) + + # Exit with test result code + sys.exit(result.returncode) + + except Exception as e: + print(f"Error executing tests: {e}") + sys.exit(1) \ No newline at end of file diff --git a/run_tests_html.py.meta b/run_tests_html.py.meta new file mode 100644 index 0000000..4ea7a74 --- /dev/null +++ b/run_tests_html.py.meta @@ -0,0 +1 @@ +Script to run all tests and generate HTML reports \ No newline at end of file diff --git a/setup_test_environment.sh b/setup_test_environment.sh new file mode 100644 index 0000000..043d2cf --- /dev/null +++ b/setup_test_environment.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# setup_test_environment.sh - Setup script for test environment + +echo "Setting up test environment..." + +# Upgrade pip +python -m pip install --upgrade pip + +# Install test dependencies +pip install pytest pytest-cov pytest-html pytest-metadata + +# Install project with test dependencies +pip install -e ".[test]" + +echo "Test environment setup complete. You can now run: python run_tests_html.py" \ No newline at end of file diff --git a/setup_test_environment.sh.meta b/setup_test_environment.sh.meta new file mode 100644 index 0000000..9be4c8a --- /dev/null +++ b/setup_test_environment.sh.meta @@ -0,0 +1 @@ +Script to setup the test environment with all required dependencies \ No newline at end of file