Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Tests relying on .bashrc being loaded not working

オープン
#275 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
bash, docker

調査の方向性

issue に記載されている commandTests の実行パスと setup entrypoint の動作から始め、提供された Debian Dockerfile と YAML ケースを再現手段として使用します。直接コマンド、bash -c、.bashrc の source、setup entrypoints における環境の扱いを比較します。関連するテストが一貫して FOO=BAR を確認できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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 :(

主要言語
Go
スター
2.5k
フォーク
213
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

GoogleContainerTools/container-structure-test のほかの issue

GoogleContainerTools/container-structure-test の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。