Skip to content
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

Test translation not following the documentation #1386

Open
wenjuno opened this issue Jan 29, 2025 · 0 comments
Open

Test translation not following the documentation #1386

wenjuno opened this issue Jan 29, 2025 · 0 comments

Comments

@wenjuno
Copy link

wenjuno commented Jan 29, 2025

I'm reading the documentation of this section: https://rattler.build/latest/testing/#how-tests-are-translated. Specifically, these points:

For a script test:

- All the files are copied straight into the test folder (under info/tests/{index}/)
- The script is turned into a run_test.sh or run_test.bat file
- The extra requirements are stored as a JSON file called test_time_dependencies.json

For a Python import test:

- A JSON file is created that is called python_test.json and stores the imports to be tested
  and whether to execute pip check or not. This file is placed under info/tests/{index}/

I like what it describes, and they can help me build tests with different configurations for the same package file. But when I try to build a package with test section and test file, the package's content does not follow what the documentation describes and the test file is stored in the package content rather than package metadata, leading to extraneous files installed to the environment. Here is an example package on Linux:

recipe.yaml

package:
  name: test_pkg3
  version: 1.0.0

tests:
  - script:
      - python run.py
      - tree $CONDA_PREFIX/etc
    requirements:
      run:
        - python
        - tree
    files:
      recipe:
        - run.py

run.py

print("Hello")

The command line is something like this:

rattler-build build -r test3 --output-dir out3

The build log shows the files that will be in the newly built package:

Files in package:
  - etc/conda/test-files/test_pkg3/0/run.py
  - info/about.json
  - info/hash_input.json
  - info/index.json
  - info/paths.json
  - info/recipe/recipe.yaml
  - info/recipe/rendered_recipe.yaml
  - info/recipe/run.py
  - info/recipe/variant_config.yaml
  - info/tests/tests.yaml

Note the test file run.py is under etc tree. The tree command in the test is to confirm that when the package is installed in an environment, the test file in etc/conda/test-files will be installed in the environment, meaning they are the content of the package rather than the metadata, which is undesirable:

+ tree $PREFIX/etc
$PREFIX/etc
└── conda
    └── test-files
        └── test_pkg3
            └── 0
                ├── build_env.sh
                ├── conda_build.sh
                └── run.py
5 directories, 3 files

In conclusion, none of the points I quoted from the documentation happens in the package, Moreover, there is one file in the test metadata info/tests/tests.yaml, which is not in the documentation. It feels the documented translation is not implemented yet? I like the design in documentation, could we implement that? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant