Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Tests relying on .bashrc being loaded not working

Abierto
#275 0 comentarios 2 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
bash, docker

Línea de trabajo

Comienza con la ruta de ejecución de commandTests y el comportamiento del setup entrypoint descrito en el issue, utilizando el Debian Dockerfile y los casos YAML proporcionados como reproductor. Compara el manejo del entorno para comandos directos, bash -c, .bashrc obtenido mediante source y setup entrypoints; se considera terminado cuando las pruebas relevantes observan FOO=BAR de forma consistente.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Go
Estrellas
2.5k
Forks
213
Métricas de merge de PR
Sin PR fusionados en 30 d

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de GoogleContainerTools/container-structure-test

Todos los issues de GoogleContainerTools/container-structure-test

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.