Skip to content

Commit

Permalink
docs: fix test documentation (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelzw authored Jan 9, 2024
1 parent 1eb0fd4 commit 3150c8c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 52 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ target/
__pycache__/
.pytest_cache/

# mkdocs
.cache

# pixi environments
.pixi
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ package as output. The `test` subcommand can be used to test existing packages
A simple example recipe for the `xtensor` header-only C++ library:

```yaml
# yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json

context:
name: xtensor
version: 0.24.6
Expand Down Expand Up @@ -127,8 +129,8 @@ requirements:
run_constrained:
- xsimd >=8.0.3,<10

test:
commands:
tests:
- script:
- if: unix or emscripten
then:
- test -d ${PREFIX}/include/xtensor
Expand Down Expand Up @@ -190,13 +192,11 @@ requirements:
- python 3.10
- typing_extensions >=4.0.0,<5.0.0

test:
imports:
- rich
commands:
- pip check
requires:
- pip
tests:
- python:
imports:
- rich
pip_check: true

about:
homepage: https://github.com/Textualize/rich
Expand Down
52 changes: 26 additions & 26 deletions docs/recipe_file.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,10 @@ requirements:
- python
# tests to validate that the package works as expected
test:
imports:
- imagesize
tests:
- python:
imports:
- imagesize
# information about the package
about:
Expand Down Expand Up @@ -372,10 +373,11 @@ build:
noarch: python
```

> ***Note***: At the time of this writing, `noarch` packages should not make use
> of preprocess-selectors: `noarch` packages are built with the directives which
> evaluate to `true` in the platform it is built on, which probably will result
> in incorrect/incomplete installation in other platforms.
!!! note
At the time of this writing, `noarch` packages should not make use
of preprocess-selectors: `noarch` packages are built with the directives which
evaluate to `true` in the platform it is built on, which probably will result
in incorrect/incomplete installation in other platforms.

<!--
### Include build recipe
Expand Down Expand Up @@ -473,7 +475,7 @@ version is part of the package dependencies, list `numpy` as a requirement in
`recipe.yaml` and use a `conda_build_config.yaml` file with multiple NumPy
versions.

### Run\_constrained
### Run constrained

Packages that are optional at runtime but must obey the supplied additional
constraint if they are installed.
Expand All @@ -484,7 +486,7 @@ specifications](https://conda.io/projects/conda/en/latest/user-guide/concepts/pk
```yaml
requirements:
run_constrained:
- optional-subpackage =={{ version }}
- optional-subpackage ==${{ version }}
```

For example, let's say we have an environment that has package "a" installed at
Expand Down Expand Up @@ -884,7 +886,7 @@ and automatically selects the right (cross-)compiler for the target platform.

```
build:
- "{{ compiler('c') }}"
- ${{ compiler('c') }}
```
The `pin_subpackage` function pins another package produced by the recipe with
Expand Down Expand Up @@ -928,8 +930,6 @@ requirements:

#### Pin compatible

**Note: not yet implemented**

Pin compatible lets you pin a package based on the version retrieved from the
variant file (if the pinning from the variant file needs customization).

Expand Down Expand Up @@ -1018,22 +1018,22 @@ Lists are automatically "merged" upwards, so it is possible to group multiple
items under a single selector:

```yaml
test:
commands:
- if: unix
then:
- test -d ${PREFIX}/include/xtensor
- test -f ${PREFIX}/lib/cmake/xtensor/xtensorConfigVersion.cmake
- if: win
then:
- if not exist %LIBRARY_PREFIX%\include\xtensor\xarray.hpp (exit 1)
- if not exist %LIBRARY_PREFIX%\lib\cmake\xtensor\xtensorConfigVersion.cmake (exit 1)
tests:
- script:
- if: unix
then:
- test -d ${PREFIX}/include/xtensor
- test -f ${PREFIX}/lib/cmake/xtensor/xtensorConfigVersion.cmake
- if: win
then:
- if not exist %LIBRARY_PREFIX%\include\xtensor\xarray.hpp (exit 1)
- if not exist %LIBRARY_PREFIX%\lib\cmake\xtensor\xtensorConfigVersion.cmake (exit 1)
# On unix this is rendered to:
test:
commands:
- test -d ${PREFIX}/include/xtensor
- test -f ${PREFIX}/lib/cmake/xtensor/xtensorConfigVersion.cmake
tests:
- script:
- test -d ${PREFIX}/include/xtensor
- test -f ${PREFIX}/lib/cmake/xtensor/xtensorConfigVersion.cmake
```

<!--
Expand Down
6 changes: 3 additions & 3 deletions examples/cargo-edit/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ requirements:
- ${{ compiler('rust') }}
- cargo-bundle-licenses

test:
commands:
- cargo-upgrade --help
tests:
- script:
- cargo-upgrade --help

about:
homepage: https://github.com/killercup/cargo-edit
Expand Down
30 changes: 16 additions & 14 deletions examples/mamba/recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/prefix-dev/recipe-format/main/schema.json

context:
name: mamba
libmamba_version: "1.5.3"
Expand Down Expand Up @@ -55,8 +57,8 @@ outputs:
- spdlog
- python
# - ${{ "python" if win }}
test:
commands:
tests:
- script:
- if: unix
then:
- test -d ${PREFIX}/include/mamba # [unix]
Expand Down Expand Up @@ -114,12 +116,13 @@ outputs:
ignore_run_exports:
by_name:
- spdlog
test:
imports:
- libmambapy
- libmambapy.bindings
commands:
- python -c "import libmambapy._version; assert libmambapy._version.__version__ == '${{ libmambapy_version }}'"
tests:
- python:
imports:
- libmambapy
- libmambapy.bindings
- script:
- python -c "import libmambapy._version; assert libmambapy._version.__version__ == '${{ libmambapy_version }}'"

- package:
name: mamba
Expand Down Expand Up @@ -148,12 +151,11 @@ outputs:
- conda >=23.9,<24
- ${{ pin_subpackage('libmambapy', exact=True) }}

test:
imports:
- mamba
requires:
- pip
commands:
tests:
- python:
imports:
- mamba
- script:
- mamba --help
# for some reason tqdm doesn't have a proper colorama dependency so pip check fails
# but that's completely unrelated to mamba
Expand Down

0 comments on commit 3150c8c

Please sign in to comment.