Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/matrix-and-codecov-on-merge-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
conda list | grep -i ipympl
fi

echo "Running tests for diffpy.cmi dependencies"
cmi install _tests
echo "Installing the pdf pack"
cmi install pdf
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/tests-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
conda list | grep -i ipympl
fi

echo "Running tests for diffpy.cmi dependencies"
cmi install _tests
echo "Installing the pdf pack"
cmi install pdf
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
10 changes: 0 additions & 10 deletions docs/source/available-profiles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,3 @@ This pack was created by members of the Billinge Group and the DiffPy community.
packs: ``core``, ``pdf``, ``plotting``

extras: ``ipykernel``

======
_tests
======

Testing and development tools for ``diffpy.cmi``.

packs: ``core``, ``pdf``, ``tests``

extras: ``_pytest.sh tar_url.txt``, ``_pytest.bat tar_url.txt``
23 changes: 23 additions & 0 deletions news/replace-tests-profile.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Add a unit test that checks a profile's extras scripts run with their arguments when the profile is installed.

**Changed:**

* Install the ``pdf`` pack in CI instead of the ``_tests`` profile.

**Deprecated:**

* <news item>

**Removed:**

* Remove the ``_tests`` profile and its ``_pytest.sh``, ``_pytest.bat`` and ``tar_url.txt`` scripts, which ran the test suites of pinned releases of ``diffpy.cmi``'s dependencies.

**Fixed:**

* <news item>

**Security:**

* <news item>
119 changes: 0 additions & 119 deletions requirements/packs/scripts/_pytest.bat

This file was deleted.

64 changes: 0 additions & 64 deletions requirements/packs/scripts/_pytest.sh

This file was deleted.

5 changes: 0 additions & 5 deletions requirements/packs/scripts/tar_url.txt

This file was deleted.

11 changes: 0 additions & 11 deletions requirements/profiles/_tests.yml

This file was deleted.

51 changes: 51 additions & 0 deletions tests/test_profilesmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,54 @@ def fake_check_profile(identifier):
captured = capsys.readouterr()
actual = captured.out
assert actual.strip() == expected.strip()


@pytest.mark.parametrize(
"script_exit_code, expected_install_exit_code",
[
# Test that installing a profile runs the scripts listed in its
# extras with their arguments and reports whether they succeeded
# C1: A user installs a profile whose script runs successfully.
# Expected: The script runs with its argument and the
# installation returns exit code 0.
(0, 0),
# C2: A user installs a profile whose script fails.
# Expected: The script runs with its argument and the
# installation returns exit code 1.
(1, 1),
],
)
def test_install_with_script_extras(
script_exit_code, expected_install_exit_code, tmp_path
):
# Write a profile that lists the same script for Linux/macOS and Windows
profiles_dir = tmp_path / "requirements" / "profiles"
profiles_dir.mkdir(parents=True)
(profiles_dir / "scripts-profile.yml").write_text(
"packs: []\n"
"\n"
"extras:\n"
" - _write_message.sh hello\n"
" - _write_message.bat hello\n"
)
# Write scripts that save their argument to a file and exit with
# script_exit_code
scripts_dir = tmp_path / "requirements" / "packs" / "scripts"
scripts_dir.mkdir(parents=True)
(scripts_dir / "_write_message.sh").write_text(
'echo "$1" > script-output.txt\n' f"exit {script_exit_code}\n"
)
(scripts_dir / "_write_message.bat").write_text(
"@echo off\n"
"echo %1> script-output.txt\n"
f"exit /b {script_exit_code}\n"
)
# Install the profile
pfm = ProfilesManager(root_path=tmp_path)
actual_install_exit_code = pfm.install("scripts-profile")
actual_script_output = (
(scripts_dir / "script-output.txt").read_text().strip()
)
expected_script_output = "hello"
assert actual_install_exit_code == expected_install_exit_code
assert actual_script_output == expected_script_output
Loading