From 0d99e3bd6d2b80ebb31d22e0c9b6606020ab4360 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:08:05 +0100 Subject: [PATCH] Add test coverage of compound bash commands (#234) The `Procfile` format supports specifying compound bash commands like: ``` web: foo && bar ``` This buildpack currently supports these, however, there is no integration test coverage of them. Having coverage is important, since some of the approaches for implementing the `bash -c` wrapping don't support usage of compound commands, as seen in: https://github.com/heroku/buildpacks-procfile/pull/150#discussion_r1180473346 As such I've added a new integration test for this, which also tests quoting (in case a future buildpack implementation starts trying to parse/escape the commands) and variable interpolation. This test case was extracted from #150 (which itself was superseded). --- .../complex_command_procfile/Procfile | 2 ++ tests/integration_test.rs | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 tests/fixtures/complex_command_procfile/Procfile diff --git a/tests/fixtures/complex_command_procfile/Procfile b/tests/fixtures/complex_command_procfile/Procfile new file mode 100644 index 0000000..acb7f82 --- /dev/null +++ b/tests/fixtures/complex_command_procfile/Procfile @@ -0,0 +1,2 @@ +# Tests use of compound bash commands, both quote styles, nested quoting and variable interpolation. +web: echo 'this is the "web" process!' && echo "\"PORT\" is set to: '${PORT}'" diff --git a/tests/integration_test.rs b/tests/integration_test.rs index ec8e481..eca66ab 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -108,6 +108,27 @@ fn test_multiple_non_web_procfile() { ); } +#[test] +#[ignore = "integration test"] +// Tests use of compound bash commands, both quote styles, nested quoting and variable interpolation. +fn test_complex_command_procfile() { + TestRunner::default().build( + BuildConfig::new( + "heroku/builder:22", + "tests/fixtures/complex_command_procfile", + ), + |context| { + context.start_container(ContainerConfig::new().env("PORT", "12345"), |container| { + let log_output = container.logs_wait(); + assert_eq!( + log_output.stdout, + "this is the \"web\" process!\n\"PORT\" is set to: '12345'\n" + ); + }); + }, + ); +} + #[test] #[ignore = "integration test"] // Tests a Procfile that happens to not be valid YAML, but is still valid according