generated from konveyor-ecosystem/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from abrugaro/add-dotnet-analysis-test
[RFR] Add hello-world dotnet analysis test
- Loading branch information
Showing
11 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"hello_world": { | ||
"app_name": "dotnet-hello-world", | ||
"file_name": "dotnet-hello-world.zip" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
- category: mandatory | ||
customVariables: [] | ||
description: MVC Method names have changed from .NET Framework | ||
effort: 1 | ||
labels: | ||
- konveyor.io/source=dotnetframework | ||
message: |- | ||
HttpNotFound was replaced with NotFound in .NET Core | ||
ruleID: removed-dotnet-framework-00000 | ||
when: | ||
or: | ||
- dotnet.referenced: | ||
pattern: "HttpNotFound" | ||
namespace: "System.Web.Mvc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: dotnet8/dotnetframework45 | ||
description: This ruleset provides analysis with respect to API changes between | ||
.NET Framework 4.5 and .NET 8. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import os | ||
import subprocess | ||
|
||
from utils import constants | ||
from utils.command import build_analysis_command | ||
from utils.common import extract_zip_to_temp_dir | ||
|
||
|
||
# Polarion TC MTA-568 | ||
def test_hello_world_analysis_with_rules(dotnet_analysis_data): | ||
# Avoid running this test on Windows | ||
if os.name == 'nt': | ||
return | ||
|
||
application_data = dotnet_analysis_data["hello_world"] | ||
application_path = os.path.join( | ||
os.getenv(constants.PROJECT_PATH), | ||
'data/applications', | ||
application_data['file_name'] | ||
) | ||
custom_rules_path = os.path.join(os.getenv(constants.PROJECT_PATH), 'data/yaml/dotnet/example_rules') | ||
|
||
with extract_zip_to_temp_dir(application_path) as tempdir: | ||
command = build_analysis_command( | ||
tempdir, | ||
"", | ||
"", | ||
**{'rules': custom_rules_path} | ||
) | ||
|
||
output = subprocess.run(command, shell=True, check=True, stdout=subprocess.PIPE, encoding='utf-8').stdout | ||
|
||
assert 'Static report created' in output |
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
import tempfile | ||
import zipfile | ||
from contextlib import contextmanager | ||
|
||
from utils import constants | ||
|
||
|
||
@contextmanager | ||
def extract_zip_to_temp_dir(application_path): | ||
""" | ||
Creates a temporary directory and extracts a zip file to it. | ||
:param application_path: Path to the zip file | ||
:yield: path to the extracted zip file | ||
""" | ||
|
||
tempdir = tempfile.TemporaryDirectory(dir=os.getenv(constants.PROJECT_PATH)) | ||
|
||
# Adjusts the permissions to allow access to subprocesses | ||
os.chmod(tempdir.name, 0o777) | ||
|
||
with zipfile.ZipFile(application_path, 'r') as zip_ref: | ||
zip_ref.extractall(tempdir.name) | ||
|
||
yield tempdir.name |