Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Tests relying on .bashrc being loaded not working

Aperta
#275 0 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
bash, docker

Direzione di ricerca

Inizia con il percorso di esecuzione di commandTests e il comportamento del setup entrypoint descritto nell’issue, utilizzando il Debian Dockerfile e i casi YAML forniti come riproduttore. Confronta la gestione dell’ambiente per i comandi diretti, bash -c, il sourcing di .bashrc e i setup entrypoints; il lavoro è completato quando i test pertinenti osservano costantemente FOO=BAR.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Go
Stelle
2.5k
Fork
213
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di GoogleContainerTools/container-structure-test

Tutte le issue di GoogleContainerTools/container-structure-test

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.