8000 Update poetry build rules to include codeanalyzer-*.jar and add a tes… · codellm-devkit/python-sdk@677be0f · GitHub
[go: up one dir, main page]

Skip to content

Commit 677be0f

Browse files
committed
Update poetry build rules to include codeanalyzer-*.jar and add a test case to verify it exists.
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
1 parent 1315c1d commit 677be0f

File tree

12 files changed

+42
-1130
lines changed

12 files changed

+42
-1130
lines changed

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,11 @@ refresh: ## Refresh code analyzer
4949
.PHONY: build
5050
build: ## Builds a new Python wheel
5151
$(info Building artifacts...)
52-
poetry build
52+
53+
# Inject the latest Code Analyzer JAR
54+
wget -q $(shell curl -s https://api.github.com/repos/IBM/codenet-minerva-code-analyzer/releases/latest | jq -r '.assets[] | .browser_download_url')
55+
mkdir -p cldk/analysis/java/codeanalyzer/jar/
56+
mv codeanalyzer-*.jar cldk/analysis/java/codeanalyzer/jar/
57+
58+
# Build the package
59+
poetry build

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ classifiers = [
2424
]
2525
include = [
2626
"LICENSE",
27-
"cldk/analysis/java/codeanalyzer/jar/codeanalyzer.jar"
27+
"cldk/analysis/java/codeanalyzer/jar/*.jar"
2828
]
2929

3030
[tool.poetry.dependencies]

tests/test_core.py

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
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"

tests/tree_sitter/__init__.py

Whitespace-only changes.

tests/tree_sitter/c/__init__.py

Whitespace-only changes.

tests/tree_sitter/c/te 579A st_c_tree_sitter.py

Lines changed: 0 additions & 261 deletions
This file was deleted.

tests/tree_sitter/go/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)
0