generated from ansys/template
-
Notifications
You must be signed in to change notification settings - Fork 18
feat: add coverage #909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+236
−29
Merged
feat: add coverage #909
Changes from all commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
cd0cbd2
fix: add codecove
Revathyvenugopal162 e17ab22
fix: add codecov secrets
Revathyvenugopal162 64513b5
fix: combine coverage
Revathyvenugopal162 f1083cc
fix: combine coverage
Revathyvenugopal162 b934919
fix: cicd
Revathyvenugopal162 d13f88d
chore: adding changelog file 909.added.md [dependabot-skip]
pyansys-ci-bot a2093d0
fix: comment preline now
Revathyvenugopal162 cde942e
Merge branch 'feat/codecov' of https://github.com/ansys/pydyna into f…
Revathyvenugopal162 09a23fb
fix: update the python
Revathyvenugopal162 bf24bda
fix: update the python
Revathyvenugopal162 608f277
fix: update the image
Revathyvenugopal162 8657c42
fix: update the actions
Revathyvenugopal162 5e129d5
fix: update the actions
Revathyvenugopal162 60f143a
fix: update the cicd
Revathyvenugopal162 4698cf2
fix: update the cicd
Revathyvenugopal162 0af52f0
fix: update the cicd
Revathyvenugopal162 c8650b0
fix: update the cicd for keyword matrix
Revathyvenugopal162 99c9c05
fix: update the cicd for keyword matrix
Revathyvenugopal162 c86bb99
fix: update the cicd for keyword matrix
Revathyvenugopal162 7b3151a
fix: update the cicd for al tests
Revathyvenugopal162 2a30856
Merge branch 'main' into feat/codecov
Revathyvenugopal162 670caf0
fix: test viz
Revathyvenugopal162 5b73796
fix: coverage results
Revathyvenugopal162 8d72371
fix: test early
Revathyvenugopal162 671272f
fix: test early
Revathyvenugopal162 f163bfb
fix: test early
Revathyvenugopal162 a61671d
fix: coverage files
Revathyvenugopal162 19b6970
fix: coverage files
Revathyvenugopal162 7e894d1
fix: coverage files
Revathyvenugopal162 7cffe17
fix: coverage files
Revathyvenugopal162 e5705ed
fix: coverage files and results
Revathyvenugopal162 af1ff53
fix: coverage files and results
Revathyvenugopal162 4c626a5
fix: coverage files and results
Revathyvenugopal162 fcfc2ef
fix: coverage files without keywords
Revathyvenugopal162 09f1956
fix: coverage files without keywords
Revathyvenugopal162 75d5706
fix: coverage files without keywords
Revathyvenugopal162 9e5b6f9
fix: coverage files without keywords
Revathyvenugopal162 c1589b0
fix: coverage files without keywords
Revathyvenugopal162 92bd673
fix: coverage files
Revathyvenugopal162 aab7908
fix: overage files name
Revathyvenugopal162 679d269
fix: overage files name
Revathyvenugopal162 e8ca676
fix: overage files name
Revathyvenugopal162 5471826
fix: coverage files
Revathyvenugopal162 1e78092
fix: coverage files
Revathyvenugopal162 76fb2f8
fix: coverage files
Revathyvenugopal162 ecf7e6d
fix: coverage files
Revathyvenugopal162 c018952
fix: coverage files
Revathyvenugopal162 ecd3fbb
fix: coverage files
Revathyvenugopal162 9a32b2d
fix: coverage files
Revathyvenugopal162 fb67ead
fix: coverage files
Revathyvenugopal162 6c1d65e
fix: coverage files zip
Revathyvenugopal162 a4d3036
fix: coverage files zip
Revathyvenugopal162 257601d
fix: coverage files zip files
Revathyvenugopal162 bdba626
fix: coverage files zip files
Revathyvenugopal162 347df57
fix: coverage to codecov
Revathyvenugopal162 2460d4c
fix: different coveage
Revathyvenugopal162 f1f3ad8
fix: different coveage to codecov
Revathyvenugopal162 9059bd7
Merge branch 'main' into feat/codecov
Revathyvenugopal162 cfc9424
fix: different coveage to codecov
Revathyvenugopal162 3b8a9dc
Merge branch 'feat/codecov' of https://github.com/ansys/pydyna into f…
Revathyvenugopal162 6990a8b
fix: different coveage flag settings
Revathyvenugopal162 f40a203
fix: update the cicd
Revathyvenugopal162 c65de8e
fix: update the indent
Revathyvenugopal162 04d9c78
fix: update the test for windows runner
Revathyvenugopal162 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,43 @@ | ||
coverage: | ||
range: 75..100 | ||
round: down | ||
precision: 2 | ||
status: | ||
project: | ||
default: | ||
target: 90% | ||
patch: off | ||
|
||
|
||
codecov: | ||
notify: | ||
wait_for_ci: yes | ||
|
||
flag_management: | ||
default_rules: # the rules that will be followed for any flag added, generally | ||
carryforward: true | ||
statuses: | ||
- type: project | ||
target: auto | ||
threshold: 1% | ||
- type: patch | ||
target: 90% | ||
individual_flags: # exceptions to the default rules above, stated flag by flag | ||
- name: run | ||
paths: | ||
- src/ansys/dyna/core/run | ||
carryforward: true | ||
statuses: | ||
- type: project | ||
target: 20% | ||
- type: patch | ||
target: 100% | ||
- name: keywords | ||
paths: | ||
- src/ansys/dyna/core/keywords #fill in your own path. Note, accepts globs, not regexes | ||
carryforward: true | ||
statuses: | ||
- type: project | ||
target: 20% | ||
- type: patch | ||
target: 100% |
This file contains hidden or 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 @@ | ||
Add coverage |
This file contains hidden or 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
This file contains hidden or 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,136 @@ | ||
import pytest | ||
from pathlib import Path | ||
from unittest.mock import MagicMock, patch | ||
|
||
import ansys.dyna.core.run.windows_runner as windows_runner | ||
from ansys.dyna.core.run.options import MpiOption, Precision | ||
|
||
|
||
@pytest.fixture | ||
def tmp_workdir(tmp_path): | ||
return tmp_path | ||
|
||
|
||
def make_runner(tmp_workdir, mpi=MpiOption.SMP, precision=Precision.SINGLE): | ||
# create dummy solver executable | ||
exe = tmp_workdir / "lsdyna.exe" | ||
exe.write_text("dummy") | ||
|
||
runner = windows_runner.WindowsRunner(executable=str(exe)) | ||
runner.mpi_option = mpi | ||
runner.precision = precision | ||
runner.input_file = "input.k" | ||
runner.working_directory = str(tmp_workdir) | ||
runner.ncpu = 4 | ||
runner.get_memory_string = MagicMock(return_value="2000m") | ||
return runner | ||
|
||
|
||
def test_find_solver_with_explicit_executable(tmp_workdir): | ||
exe = tmp_workdir / "lsdyna.exe" | ||
exe.write_text("dummy") | ||
|
||
runner = windows_runner.WindowsRunner(executable=str(exe)) | ||
assert runner.solver_location == str(tmp_workdir) | ||
assert runner.solver.endswith("lsdyna.exe\"") | ||
|
||
|
||
@patch("ansys.dyna.core.run.windows_runner._get_unified_install_base_for_version") | ||
def test_find_solver_with_version(mock_install_base, tmp_workdir): | ||
exe = tmp_workdir / "ansys" / "bin" / "winx64" / "lsdyna_sp.exe" | ||
exe.parent.mkdir(parents=True) | ||
exe.write_text("dummy") | ||
|
||
mock_install_base.return_value = (tmp_workdir, None) | ||
runner = windows_runner.WindowsRunner(version=241, precision=Precision.SINGLE) | ||
assert runner.solver.endswith("lsdyna_sp.exe\"") | ||
|
||
def test_find_solver_executable_not_found(tmp_workdir): | ||
with pytest.raises(FileNotFoundError): | ||
windows_runner.WindowsRunner(executable=str(tmp_workdir / "missing.exe")) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"mpi,prec,expected", | ||
[ | ||
(MpiOption.SMP, Precision.SINGLE, "lsdyna_sp.exe"), | ||
(MpiOption.SMP, Precision.DOUBLE, "lsdyna_dp.exe"), | ||
(MpiOption.MPP_INTEL_MPI, Precision.SINGLE, "lsdyna_mpp_sp_impi.exe"), | ||
(MpiOption.MPP_INTEL_MPI, Precision.DOUBLE, "lsdyna_mpp_dp_impi.exe"), | ||
(MpiOption.MPP_MS_MPI, Precision.SINGLE, "lsdyna_mpp_sp_msmpi.exe"), | ||
(MpiOption.MPP_MS_MPI, Precision.DOUBLE, "lsdyna_mpp_dp_msmpi.exe"), | ||
], | ||
) | ||
def test_get_exe_name_variants(tmp_workdir, mpi, prec, expected): | ||
runner = make_runner(tmp_workdir, mpi, prec) | ||
assert runner._get_exe_name() == expected | ||
|
||
|
||
def test_get_env_script_intel(tmp_workdir): | ||
runner = make_runner(tmp_workdir, MpiOption.MPP_INTEL_MPI) | ||
(tmp_workdir / "lsprepost_foo").mkdir() | ||
script = runner._get_env_script() | ||
assert script.endswith("lsdynaintelvar.bat") | ||
|
||
|
||
def test_write_runscript(tmp_workdir): | ||
runner = make_runner(tmp_workdir) | ||
runner._get_command_line = MagicMock(return_value="echo hello") | ||
runner._write_runscript() | ||
script_path = tmp_workdir / runner._scriptname | ||
assert "echo hello" in script_path.read_text() | ||
|
||
|
||
@patch("ansys.dyna.core.run.windows_runner.subprocess.Popen") | ||
def test_run_success(mock_popen, tmp_workdir): | ||
runner = make_runner(tmp_workdir) | ||
runner._get_command_line = MagicMock(return_value="echo hello") | ||
|
||
process = MagicMock() | ||
process.poll.side_effect = [None, 0] | ||
process.wait.return_value = 0 | ||
process.returncode = 0 | ||
mock_popen.return_value = process | ||
|
||
# fake log file | ||
log_file = tmp_workdir / "lsrun.out.txt" | ||
log_file.write_text("all good\n") | ||
|
||
runner.run() | ||
assert process.wait.called | ||
|
||
|
||
@patch("ansys.dyna.core.run.windows_runner.subprocess.Popen") | ||
def test_run_with_warning_logs(mock_popen, tmp_workdir, caplog): | ||
runner = make_runner(tmp_workdir) | ||
runner._get_command_line = MagicMock(return_value="echo hello") | ||
|
||
process = MagicMock() | ||
process.poll.side_effect = [None, 0] | ||
process.wait.return_value = 0 | ||
process.returncode = 0 | ||
mock_popen.return_value = process | ||
|
||
log_file = tmp_workdir / "lsrun.out.txt" | ||
log_file.write_text("Warning: something\n") | ||
|
||
runner.run() | ||
assert "completed with warnings" in caplog.text | ||
|
||
|
||
@patch("ansys.dyna.core.run.windows_runner.subprocess.Popen") | ||
def test_run_failure(mock_popen, tmp_workdir): | ||
runner = make_runner(tmp_workdir) | ||
runner._get_command_line = MagicMock(return_value="echo hello") | ||
|
||
process = MagicMock() | ||
process.poll.side_effect = [0] | ||
process.wait.return_value = 1 | ||
process.returncode = 1 | ||
mock_popen.return_value = process | ||
|
||
log_file = tmp_workdir / "lsrun.out.txt" | ||
log_file.write_text("Error: fail\n") | ||
|
||
with pytest.raises(RuntimeError): | ||
runner.run() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.