Allow to set `building` in the tests dict

Đang mở
#2,240 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 3 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
build-system

Hướng nghiên cứu

This is a proposal to accept a building key in each tests entry so a test runs in the same environment as rez env --build <pkg>. Start with the issue's example and the rez docs on the building attribute and tests, then read #2211, which the issue depends on. Done means a test entry with building: True gets the build environment, including build-only requires, and other tests are unchanged. Since the design is still open, check with maintainers before writing code.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement

A stepping stone to #2211 — or some variant of that — is to be able to set the building attribute for a test in the tests dict.

It would look something like:

def commands():
    if building:
        env.PKG_CONFIG_PATH.prepend("{root}/lib/pkgconfig")

tests = {
    "pkgconf": {
        "command": "pkg-config mylib",
        "requires": ["pkgconf"],
        "building": True,
        "run_on": ["default", "pre_release"]
    },
}

The environment would be equivalent to the one you get with rez env --build <current_pkg> + <testing_pkgs>

Motivation

I encountered an issue when trying to add some tests for a C++ package. Our packages only prepend things to PKG_CONFIG_PATH or CMAKE_PREFIX_PATH when building is true. Similar to what the rez documentation for the building attribute shows with the env.FOO_INCLUDE_PATH example.

A workaround would be to change if building: to if building or testing:. But you don't necessarily want the build specific options for all of your tests. Most tests you would want the environment to be as when you run rez env <current_pkg>.

And in our case that would require a lot of effort. I did a quick grep and we have ~430 rez releases with if building:, not all of them are still in use but a substantial chunk of them would need to be fixed.

Another thing that if building and testing:wouldn't fix, is the build specific dependencies you get when specifying rez env --build. Those you would need to manually add to the test's requires in order to get a similar environment as the building environment.

Having the option to opt-in to a build environment for a given test would solve all of this and avoid muddying the waters between the building and testing attribute.

This would allow us to test things like if the pkgconfig file a package generated works as expected. And run source specific tests with some gotchas.

Related Issues/PRs

  • #2211
Ngôn ngữ chính
Python
Star
1.1k
Fork
370
Merge trung bình
4 ngày 9 giờ
Pull request đã merge (30 ngày)
11

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AcademySoftwareFoundation/rez

Tất cả issue của AcademySoftwareFoundation/rez

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.