|
13 | 13 | from urllib.request import urlretrieve |
14 | 14 |
|
15 | 15 |
|
16 | | -@pytest.fixture(scope="session", autouse=True) |
17 | | -def test_fixture(application: str = ''): |
18 | | - """ |
19 | | - Returns the path to the test data directory. |
20 | | -
|
21 | | - Yields: |
22 | | - Path : The path to the test data directory. |
23 | | - """ |
24 | | - # ----------------------------------[ SETUP ]---------------------------------- |
25 | | - # Path to your pyproject.toml |
26 | | - pyproject_path = Path(__file__).parent.parent.parent.parent / "pyproject.toml" |
27 | | - |
28 | | - # Load the configuration |
29 | | - config = toml.load(pyproject_path) |
30 | | - |
31 | | - # Access the test data path |
32 | | - test_data_path = config["tool"]["cldk"]["testing"]["sample-application"] |
33 | | - |
34 | | - if not Path(__file__).parent.parent.parent.parent.joinpath(test_data_path).exists(): |
35 | | - Path(test_data_path).mkdir(parents=True) |
36 | | - if application == "daytrader": |
37 | | - url = "https://github.com/OpenLiberty/sample.daytrader8/archive/refs/tags/v1.2.zip" |
38 | | - filename = Path(test_data_path).absolute() / "v1.2.zip" |
39 | | - elif application == "CLI" or application == "": |
40 | | - url = "https://github.com/apache/commons-cli/archive/refs/tags/commons-cli-1.8.0-RC2.zip" |
41 | | - filename = Path(__file__).parent.parent.parent.parent.joinpath(test_data_path).joinpath("commons-cli-1.8.0-RC2.zip") |
42 | | - urlretrieve(url, filename) |
43 | | - |
44 | | - # Extract the zip file to the test data path |
45 | | - with zipfile.ZipFile(filename, "r") as zip_ref: |
46 | | - zip_ref.extractall(Path(__file__).parent.parent.parent.parent.joinpath(test_data_path)) |
47 | | - |
48 | | - # Remove the zip file |
49 | | - filename.unlink() |
50 | | - # -------------------------------------------------------------------------------- |
51 | | - if application == "daytrader": |
52 | | - # Daytrader8 sample application path |
53 | | - yield Path(Path(__file__).parent.parent.parent.parent.joinpath(test_data_path)) / "sample.daytrader8-1.2" |
54 | | - else: |
55 | | - yield Path(Path(__file__).parent.parent.parent.parent.joinpath(test_data_path)) / "commons-cli-commons-cli-1.8.0-RC2" |
56 | | - |
57 | | - # -----------------------------------[ TEARDOWN ]---------------------------------- |
58 | | - # Remove the daytrader8 sample application that was downloaded for testing |
59 | | - for directory in Path(test_data_path).iterdir(): |
60 | | - if directory.exists() and directory.is_dir(): |
61 | | - shutil.rmtree(directory) |
62 | | - # --------------------------------------------------------------------------------- |
63 | | - |
64 | | - |
65 | | -@pytest.mark.parametrize('test_fixture', ['daytrader'], indirect=['test_fixture']) |
66 | | -def test_get_class_call_graph(test_fixture): |
| 16 | +# @pytest.mark.parametrize("test_fixture", ["daytrader"], indirect=["test_fixture"]) |
| 17 | +def test_get_class_call_graph(test_fixture, codeanalyzer_jar_path): |
67 | 18 | # Initialize the CLDK object with the project directory, language, and analysis_backend. |
68 | 19 | cldk = CLDK(language="java") |
69 | 20 |
|
70 | 21 | analysis = cldk.analysis( |
71 | 22 | project_path=test_fixture, |
72 | 23 | analysis_backend="codeanalyzer", |
73 | | - analysis_json_path="../../../tests/resources/java/analysis_db", |
| 24 | + analysis_backend_path=codeanalyzer_jar_path, |
74 | 25 | eager=True, |
75 | | - analysis_level=AnalysisLevel.call_graph |
| 26 | + analysis_level=AnalysisLevel.call_graph, |
76 | 27 | ) |
77 | 28 | class_call_graph: List[Tuple[JMethodDetail, JMethodDetail]] = analysis.get_class_call_graph( |
78 | 29 | qualified_class_name="com.ibm.websphere.samples.daytrader.impl.direct.TradeDirectDBUtils" |
79 | 30 | ) |
80 | | - |
81 | 31 | assert class_call_graph is not None |
82 | 32 |
|
83 | 33 |
|
84 | | -@pytest.mark.parametrize('test_fixture', ['CLI'], indirect=['test_fixture']) |
85 | | -def test_get_class_call_graph_using_symbol_table(test_fixture): |
86 | | - # Initialize the CLDK object with the project directory, language, and analysis_backend. |
87 | | - cldk = CLDK(language="java") |
| 34 | +# @pytest.mark.parametrize("test_fixture", ["CLI"], indirect=["test_fixture"]) |
| 35 | +# def test_get_class_call_graph_using_symbol_table(test_fixture): |
| 36 | +# # Initialize the CLDK object with the project directory, language, and analysis_backend. |
| 37 | +# cldk = CLDK(language="java") |
88 | 38 |
|
89 | | - analysis = cldk.analysis( |
90 | | - project_path=test_fixture, |
91 | | - analysis_backend="codeanalyzer", |
92 | | - analysis_json_path="../../../tests/resources/java/analysis_db", |
93 | | - eager=False, |
94 | | - analysis_level=AnalysisLevel.symbol_table |
95 | | - ) |
96 | | - class_call_graph: List[Tuple[JMethodDetail, JMethodDetail]] = analysis.get_class_call_graph( |
97 | | - qualified_class_name="org.apache.commons.cli.DefaultParser", |
98 | | - method_signature="handleConcatenatedOptions(String)", |
99 | | - using_symbol_table=True |
100 | | - ) |
| 39 | +# analysis = cldk.analysis( |
| 40 | +# project_path=test_fixture, |
| 41 | +# analysis_backend="codeanalyzer", |
| 42 | +# analysis_json_path="../../../tests/resources/java/analysis_db", |
| 43 | +# eager=False, |
| 44 | +# analysis_level=AnalysisLevel.symbol_table, |
| 45 | +# ) |
| 46 | +# class_call_graph: List[Tuple[JMethodDetail, JMethodDetail]] = analysis.get_class_call_graph( |
| 47 | +# qualified_class_name="org.apache.commons.cli.DefaultParser", method_signature="handleConcatenatedOptions(String)", using_symbol_table=True |
| 48 | +# ) |
101 | 49 |
|
102 | | - assert class_call_graph is not None |
| 50 | +# assert class_call_graph is not None |
0 commit comments