Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing command from failed context.run_shell_command invocations #892

Open
schneems opened this issue Dec 11, 2024 · 0 comments
Open

Missing command from failed context.run_shell_command invocations #892

schneems opened this issue Dec 11, 2024 · 0 comments
Labels
enhancement New feature or request libcnb-test

Comments

@schneems
Copy link
Contributor

Context

When using run_shell_command in an integration test:

    TestRunner::default().build(
        config,
        |context| {
            println!("{}", context.pack_stdout);
            assert_contains!(context.pack_stdout, "# Heroku Ruby Buildpack");
            assert_contains!(
                context.pack_stdout,
                r#"`BUNDLE_BIN="/layers/heroku_ruby/gems/bin" BUNDLE_CLEAN="1" BUNDLE_DEPLOYMENT="1" BUNDLE_GEMFILE="/workspace/Gemfile" BUNDLE_PATH="/layers/heroku_ruby/gems" BUNDLE_WITHOUT="development:test" bundle install`"#);

            assert_contains!(context.pack_stdout, "Installing puma");

            let secret_key_base = context.run_shell_command("echo \"${SECRET_KEY_BASE:?No SECRET_KEY_BASE set}").stdout;

Expected

If the command fails the full command will be presented to the user on error.

Actual

The command is not always presented back to the user, in this case here's the output:

thread 'test_default_app_latest_distro' panicked at /Users/rschneeman/.cargo/registry/src/index.crates.io-6f17d22bba15001f/libcnb-test-0.25.0/src/test_context.rs:194:43:
Error running container:

docker command failed with exit code 2!

## stderr:

bash: -c: line 1: unexpected EOF while looking for matching `"'

## stdout:



note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    test_default_app_latest_distro

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 6 filtered out; finished in 13.85s

It will show for other cases like trying to run "doesnotexist" but it would be easier to see that there's a missing quotation mark if the full command is visible in the error output like:

Error running command `echo "${SECRET_KEY_BASE:?No SECRET_KEY_BASE set}`

...

Or something similar.

@edmorley edmorley added libcnb-test enhancement New feature or request labels Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request libcnb-test
Projects
None yet
Development

No branches or pull requests

2 participants