Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Tests relying on .bashrc being loaded not working

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

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

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
bash, docker
Lĩnh vực
testing-qa, tooling

Hướng nghiên cứu

Bắt đầu với luồng thực thi commandTests và hành vi của setup entrypoint được mô tả trong issue, sử dụng Debian Dockerfile và các trường hợp YAML được cung cấp làm bộ tái hiện. So sánh cách xử lý môi trường đối với các lệnh trực tiếp, bash -c, việc source .bashrc và các setup entrypoints; hoàn tất khi các kiểm thử liên quan nhất quán quan sát thấy FOO=BAR.

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

Mô tả

Hi all.
First of all... great library, really like the simplicity of it.

We have a fairly rich docker container that makes heavy use of bash scripting to dynamically define env variables in the ~/,bashrc. After trying all kind of things for the last days I cannot get container structure tests to work in the context of the bashrc. Whatever I do, the env vars seem to be undefined.

Here's an example Dockerfile I wrote up:

FROM debian:buster

RUN echo "export FOO=BAR" >> /root/.bashrc
RUN echo "echo 'bashrc loaded!'" >> ~/.bashrc

# this is strictly seen not necessary, but it forces the bashrc to be always loaded, not just in interactive mode and suppresses a related warning:
ENV BASH_ENV=/root/.bashrc

These are my example tests - they all fail.
The output indicates that the .bashrc is actually loaded, but the actual test seems to run separately under a different context - FOO seems never defined in the test context and the output of $FOO is always blank.

schemaVersion: 2.0.0

commandTests:
  - name: "echo FOO"
    command: echo
    args: [ "$FOO" ]
    expectedOutput: [ "BAR" ]
  - name: "echo FOO using bash -c wrapper and enumerated args"
    command: "bash"
    args:
      - -c
      - "echo $FOO"
    expectedOutput: [ "BAR" ]
  - name: "echo FOO using bash -c wrapper and string array args"
    command: "bash"
    args: ["-c", "echo $FOO"]
    expectedOutput: [ "BAR" ]
  - name: "echo FOO using bash -c wrapper, pipe and source .bashrc"
    command: "bash"
    args:
      - -c
      - |
          source ~/.bashrc &&
          echo $FOO
    expectedOutput: [ "BAR" ]

I also tried to specify a custom entry point using setup: [["entrypoint.sh"]] with the same result.
entrypoint.sh:

#!/bin/bash
source /root/.bashrc

Any help is greatly appreciated!
We already wrote fair a bit of non-bash tests, but cannot use this framework without proper bash support :(

Ngôn ngữ chính
Go
Star
2.5k
Fork
213
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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 GoogleContainerTools/container-structure-test

Tất cả issue của GoogleContainerTools/container-structure-test

Issue tương tự

Thêm issue về Go

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.