|
1 | | -# def test_specifiy_codeanalyzer_backend_manually(test_fixture): |
2 | | -# # Initialize the CLDK object with the project directory, language, and backend. |
3 | | -# ns = CLDK( |
4 | | -# project_dir=test_fixture[0], |
5 | | -# language="java", |
6 | | -# backend="codeanalyzer", |
7 | | -# backend_path=test_fixture[1], |
8 | | -# analysis_db="/tmp", |
9 | | -# sdg=True, |
10 | | -# use_graalvm_binary=False, |
11 | | -# eager=True, |
12 | | -# ) |
13 | | -# classes_dict = ns.preprocessing.get_all_classes() |
14 | | -# assert len(classes_dict) > 0 |
15 | | - |
16 | | - |
17 | | -# def test_get_all_calsses(test_fixture): |
18 | | -# # Initialize the CLDK object with the project directory, language, and analysis_backend. |
19 | | -# ns = CLDK( |
20 | | -# project_dir=test_fixture[0], |
21 | | -# language="java", |
22 | | -# analysis_backend="codeanalyzer", |
23 | | -# analysis_json_path="/tmp", |
24 | | -# sdg=True, |
25 | | -# use_graalvm_binary=False, |
26 | | -# ) |
27 | | -# classes_dict = ns.analysis.get_all_classes() |
28 | | -# assert len(classes_dict) == 148 |
| 1 | +"""Test core functionalities of the build process.""" |
| 2 | + |
| 3 | +import glob |
| 4 | +from pdb import set_trace |
| 5 | +from pathlib import Path |
| 6 | +import re |
| 7 | +from subprocess import run |
| 8 | +import zipfile |
| 9 | + |
| 10 | +import pytest |
| 11 | + |
| 12 | + |
| 13 | +@pytest.fixture(scope="session") |
| 14 | +def build_project(): |
| 15 | + # Run the Poetry build command |
| 16 | + result = run(["poetry", "build"], capture_output=True, text=True) |
| 17 | + assert result.returncode == 0, f"Poetry build failed: {result.stderr}" |
| 18 | + |
| 19 | + # Find the .whl file in the dist directory |
| 20 | + wheel_files = glob.glob("dist/*.whl") |
| 21 | + assert wheel_files, "No .whl file found in the dist directory" |
| 22 | + return wheel_files[0] |
| 23 | + |
| 24 | + |
| 25 | +def test_codeanalyzer_jar_in_wheel(build_project): |
| 26 | + wheel_path = build_project |
| 27 | + jar_pattern = re.compile(r"cldk/analysis/java/codeanalyzer/jar/codeanalyzer-.*\.jar") |
| 28 | + |
| 29 | + # Open the .whl file as a zip archive and check for the jar file |
| 30 | + with zipfile.ZipFile(wheel_path, "r") as wheel_zip: |
| 31 | + jar_files = [file for file in wheel_zip.namelist() if jar_pattern.match(file)] |
| 32 | + |
| 33 | + assert jar_files, "codeanalyzer-*.jar file not found in the wheel package" |
0 commit comments