Skip to content

Commit

Permalink
Fix integration tests that match output
Browse files Browse the repository at this point in the history
  • Loading branch information
Malax committed Dec 20, 2024
1 parent bebe2c2 commit 50fc0dd
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 30 deletions.
3 changes: 1 addition & 2 deletions buildpacks/jvm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ impl Buildpack for OpenJdkBuildpack {
To set the OpenJDK version, add or edit the system.properties file in the root
directory of your application to contain:
java.runtime.version = {OPENJDK_LATEST_LTS_VERSION}
"},
java.runtime.version = {OPENJDK_LATEST_LTS_VERSION}"},
);
}

Expand Down
32 changes: 14 additions & 18 deletions buildpacks/jvm/tests/integration/versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ fn openjdk_default() {
assert_contains!(
context.pack_stderr,
&formatdoc! {"
[Warning: No OpenJDK version specified]
Your application does not explicitly specify an OpenJDK version. The latest
long-term support (LTS) version will be installed. This currently is OpenJDK 21.
This default version will change when a new LTS version is released. Your
application might fail to build with the new version. We recommend explicitly
setting the required OpenJDK version for your application.
To set the OpenJDK version, add or edit the system.properties file in the root
directory of your application to contain:
java.runtime.version = 21
"}
);
! WARNING: No OpenJDK version specified
!
! Your application does not explicitly specify an OpenJDK version. The latest
! long-term support (LTS) version will be installed. This currently is OpenJDK 21.
!
! This default version will change when a new LTS version is released. Your
! application might fail to build with the new version. We recommend explicitly
! setting the required OpenJDK version for your application.
!
! To set the OpenJDK version, add or edit the system.properties file in the root
! directory of your application to contain:
!
! java.runtime.version = 21"});

assert_contains!(
context.run_shell_command("java -version").stderr,
Expand All @@ -53,10 +52,7 @@ fn openjdk_functions_default() {
BuildpackReference::WorkspaceBuildpack(buildpack_id!("heroku/maven")),
]),
|context| {
assert_not_contains!(
context.pack_stderr,
"[Warning: No OpenJDK version specified]"
);
assert_not_contains!(context.pack_stderr, "No OpenJDK version specified");

assert_contains!(
context.run_shell_command("java -version").stderr,
Expand Down
1 change: 0 additions & 1 deletion buildpacks/maven/tests/integration/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ fn no_internal_maven_options_logging() {
|context| {
assert_not_contains!(context.pack_stdout, "-Dmaven.repo.local=");
assert_not_contains!(context.pack_stdout, "-Duser.home=");
assert_not_contains!(context.pack_stdout, "dependency:list");
assert_not_contains!(
context.pack_stdout,
"-DoutputFile=target/mvn-dependency-list.log"
Expand Down
12 changes: 6 additions & 6 deletions buildpacks/maven/tests/integration/versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::path::Path;
#[ignore = "integration test"]
fn with_wrapper() {
TestRunner::default().build( default_build_config("test-apps/simple-http-service"), |context| {
assert_not_contains!(context.pack_stdout, "Selected Maven version:");
assert_contains!(context.pack_stdout, "Maven wrapper detected, skipping installation.");
assert_contains!(context.pack_stdout, "$ ./mvnw");
assert_not_contains!(context.pack_stdout, " - Selected Maven version");
assert_contains!(context.pack_stdout, "- Skipping (Maven wrapper detected)");
assert_contains!(context.pack_stdout, " - Running `./mvnw");
assert_contains!(context.pack_stdout, &format!("[BUILDPACK INTEGRATION TEST - MAVEN VERSION] {SIMPLE_HTTP_SERVICE_MAVEN_WRAPPER_VERSION}"));
});
}
Expand All @@ -25,7 +25,7 @@ fn with_wrapper_and_system_properties() {
|context| {
assert_contains!(
context.pack_stdout,
&format!("Selected Maven version: {DEFAULT_MAVEN_VERSION}")
&format!(" - Selected Maven version `{DEFAULT_MAVEN_VERSION}`")
);
assert_not_contains!(context.pack_stdout, "$ ./mvnw");
assert_contains!(
Expand Down Expand Up @@ -61,7 +61,7 @@ fn without_wrapper_and_without_system_properties() {
assert_not_contains!(context.pack_stdout, "$ ./mvnw");
assert_contains!(
context.pack_stdout,
&format!("Selected Maven version: {DEFAULT_MAVEN_VERSION}")
&format!(" - Selected Maven version `{DEFAULT_MAVEN_VERSION}`")
);
assert_contains!(
context.pack_stdout,
Expand Down Expand Up @@ -95,7 +95,7 @@ fn without_wrapper_and_maven_3_9_4_system_properties() {
set_maven_version_app_dir_preprocessor("3.9.4", &path);
}),
|context| {
assert_contains!(context.pack_stdout, "Selected Maven version: 3.9.4");
assert_contains!(context.pack_stdout, " - Selected Maven version `3.9.4`");
assert_contains!(
context.pack_stdout,
"[BUILDPACK INTEGRATION TEST - MAVEN VERSION] 3.9.4"
Expand Down
2 changes: 1 addition & 1 deletion shared/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod fs;
pub mod log;
pub mod output;
pub mod result;
pub mod system_properties;
pub mod output;
4 changes: 2 additions & 2 deletions shared/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn print_warning(title: impl AsRef<str>, body: impl Into<BuildpackOutputText
..BuildpackOutputText::default()
};

println!("{}", text.to_ansi_string());
eprintln!("{}", text.to_ansi_string());
}

pub fn print_error(title: impl AsRef<str>, body: impl Into<BuildpackOutputText>) {
Expand All @@ -59,7 +59,7 @@ pub fn print_error(title: impl AsRef<str>, body: impl Into<BuildpackOutputText>)
..BuildpackOutputText::default()
};

println!("{}", text.to_ansi_string());
eprintln!("{}", text.to_ansi_string());
}

pub fn run_command<E, F: FnOnce(std::io::Error) -> E, F2: FnOnce(Output) -> E>(
Expand Down

0 comments on commit 50fc0dd

Please sign in to comment.