From 7761d9e281e8a57ee6a828381df0fb0b77c0bbbf Mon Sep 17 00:00:00 2001 From: Manuel Fuchs Date: Fri, 27 Jun 2025 13:08:58 +0200 Subject: [PATCH] Port Hatchet tests to rusty_hatchet --- .gitignore | 1 + Cargo.lock | 1018 +++++++++++++++++++++++++++++++ Cargo.toml | 11 + src/main.rs | 3 + tests/automatic_process_type.rs | 10 + tests/caching.rs | 15 + tests/customization.rs | 40 ++ tests/misc.rs | 94 +++ tests/polyglot.rs | 14 + tests/settings_xml.rs | 188 ++++++ tests/smoke.rs | 18 + tests/versions.rs | 174 ++++++ 12 files changed, 1586 insertions(+) create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs create mode 100644 tests/automatic_process_type.rs create mode 100644 tests/caching.rs create mode 100644 tests/customization.rs create mode 100644 tests/misc.rs create mode 100644 tests/polyglot.rs create mode 100644 tests/settings_xml.rs create mode 100644 tests/smoke.rs create mode 100644 tests/versions.rs diff --git a/.gitignore b/.gitignore index 8507f97a..d89aa822 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ target .DS_Store .rspec_status test/spec/fixtures/repos/github +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 00000000..f84df302 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1018 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + +[[package]] +name = "bitflags" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" + +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + +[[package]] +name = "cc" +version = "1.2.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d487aa071b5f64da6f19a3e848e3578944b726ee5a4854b82172f02aa876bfdc" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "errno" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" +dependencies = [ + "libc", + "windows-sys 0.60.2", +] + +[[package]] +name = "fancy-regex" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e24cb5a94bcae1e5408b0effca5cd7172ea3c5755049c5f3af4cd283a165298" +dependencies = [ + "bit-set", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "flate2" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d" +dependencies = [ + "crc32fast", + "miniz_oxide", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + +[[package]] +name = "heroku-buildpack-java" +version = "0.1.0" +dependencies = [ + "indoc", + "java-properties", + "regex", + "rusty-hatchet", + "url", +] + +[[package]] +name = "http" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "icu_collections" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" + +[[package]] +name = "icu_properties" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "potential_utf", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" + +[[package]] +name = "icu_provider" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +dependencies = [ + "displaydoc", + "icu_locale_core", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indoc" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c7245a08504955605670dbf141fceab975f15ca21570696aebe9d2e71576bd" + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "java-properties" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37bf6f484471c451f2b51eabd9e66b3fa7274550c5ec4b6c3d6070840945117f" +dependencies = [ + "encoding_rs", + "lazy_static", + "regex", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.174" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "litemap" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "memchr" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "potential_utf" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +dependencies = [ + "zerovec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustix" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustls" +version = "0.23.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7160e3e10bf4535308537f3c4e1641468cd0e485175d6163087c0393c7d46643" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a72fe2bcf7a6ac6fd7d0b9e5cb68aeb7d4c0a0271730218b3e92d43b4eb435" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rusty-hatchet" +version = "0.1.0" +dependencies = [ + "fancy-regex", + "fastrand", + "fs_extra", + "serde", + "serde_json", + "tempfile", + "thiserror", + "ureq", + "url", +] + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tempfile" +version = "3.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" +dependencies = [ + "fastrand", + "getrandom 0.3.3", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tinystr" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "3.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f0fde9bc91026e381155f8c67cb354bcd35260b2f4a29bcc84639f762760c39" +dependencies = [ + "base64", + "flate2", + "log", + "percent-encoding", + "rustls", + "rustls-pemfile", + "rustls-pki-types", + "ureq-proto", + "utf-8", + "webpki-roots 0.26.11", +] + +[[package]] +name = "ureq-proto" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59db78ad1923f2b1be62b6da81fe80b173605ca0d57f85da2e005382adf693f7" +dependencies = [ + "base64", + "http", + "httparse", + "log", +] + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "webpki-roots" +version = "0.26.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521bc38abb08001b01866da9f51eb7c5d647a19260e00054a8c7fd5f9e57f7a9" +dependencies = [ + "webpki-roots 1.0.1", +] + +[[package]] +name = "webpki-roots" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8782dd5a41a24eed3a4f40b606249b3e236ca61adf1f25ea4d45c73de122b502" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.2", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c66f69fcc9ce11da9966ddb31a40968cad001c5bedeb5c2b82ede4253ab48aef" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] + +[[package]] +name = "writeable" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" + +[[package]] +name = "yoke" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerotrie" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 00000000..366cc37f --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "heroku-buildpack-java" +version = "0.1.0" +edition = "2024" + +[dev-dependencies] +rusty-hatchet = { path ="../rusty-hatchet" } +indoc = "2" +regex = "1" +url = "2" +java-properties = "2" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 00000000..e7a11a96 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/tests/automatic_process_type.rs b/tests/automatic_process_type.rs new file mode 100644 index 00000000..1e910996 --- /dev/null +++ b/tests/automatic_process_type.rs @@ -0,0 +1,10 @@ +use rusty_hatchet; +use rusty_hatchet::{assert_contains, BuildConfig, TestRunner}; +use rusty_hatchet::HerokuStack::Heroku24; + +#[test] +fn sprint_boot_automatic_process_type() { + TestRunner::default().build(BuildConfig::new(Heroku24, "test/spec/fixtures/repos/buildpack-java-spring-boot-test"), |context| { + assert_eq!(context.http_request("/").unwrap(), "Hello from Spring Boot!"); + }); +} diff --git a/tests/caching.rs b/tests/caching.rs new file mode 100644 index 00000000..7377b01a --- /dev/null +++ b/tests/caching.rs @@ -0,0 +1,15 @@ +use rusty_hatchet::{assert_contains, assert_not_contains, BuildConfig, TestRunner}; +use rusty_hatchet::HerokuStack::Heroku24; + +#[test] +fn sprint_boot_automatic_process_type() { + let config = BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service"); + + TestRunner::default().build(config.clone(), |context| { + assert_contains!(context.build_output, "Downloading from central"); + + context.rebuild(config, |context| { + assert_not_contains!(context.build_output, "Downloading from central"); + }); + }); +} diff --git a/tests/customization.rs b/tests/customization.rs new file mode 100644 index 00000000..66a7d50f --- /dev/null +++ b/tests/customization.rs @@ -0,0 +1,40 @@ +use rusty_hatchet::HerokuStack::Heroku24; +use rusty_hatchet::{BuildConfig, TestRunner, assert_contains, assert_not_contains}; + +#[test] +fn maven_custom_goals() { + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .env("MAVEN_CUSTOM_GOALS", "site"), + |context| { + assert_contains!(context.build_output, "./mvnw -DskipTests site"); + assert_contains!( + context.build_output, + "[INFO] --- maven-site-plugin:3.7.1:site (default-site) @ simple-http-service ---" + ); + }, + ); +} + +#[test] +fn maven_custom_opts() { + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .env("MAVEN_CUSTOM_OPTS", "-X"), + |context| { + assert_contains!( + context.build_output, + "./mvnw -X clean dependency:list install" + ); + + assert_contains!(context.build_output, "[DEBUG] -- end configuration --"); + + // -DskipTests is part of the default Maven options. We expect it to be overridden by MAVEN_CUSTOM_OPTS and + // therefore expect Maven to run tests. + assert_contains!( + context.build_output, + "[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0" + ); + }, + ); +} diff --git a/tests/misc.rs b/tests/misc.rs new file mode 100644 index 00000000..c35b776e --- /dev/null +++ b/tests/misc.rs @@ -0,0 +1,94 @@ +use indoc::indoc; +use rusty_hatchet::HerokuStack::Heroku24; +use rusty_hatchet::{ + BuildConfig, BuildResult, TestRunner, assert_contains, assert_contains_match, + assert_not_contains, +}; +use std::fs::Permissions; +use std::os::unix::fs::PermissionsExt; + +#[test] +fn maven_wrapper_without_executable_bit() { + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .app_dir_preprocessor(|path| { + let maven_wrapper = path.join("mvnw"); + + let permissions = maven_wrapper.metadata().unwrap().permissions(); + let new_permissions = Permissions::from_mode(permissions.mode() | 0o666); + + std::fs::set_permissions(&maven_wrapper, new_permissions).unwrap(); + }), + |context| { + assert_contains!(context.build_output, "[INFO] BUILD SUCCESS"); + }, + ); +} + +#[test] +fn dependency_list() { + let config = BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service"); + + TestRunner::default().build(config.clone(), |context| { + assert_eq!( + context + .run_shell_command("cat target/mvn-dependency-list.log") + .stdout, + indoc! {" + + The following files have been resolved: + io.undertow:undertow-core:jar:2.3.17.Final:compile + org.jboss.logging:jboss-logging:jar:3.4.3.Final:compile + org.jboss.xnio:xnio-api:jar:3.8.16.Final:compile + org.wildfly.common:wildfly-common:jar:1.5.4.Final:compile + org.wildfly.client:wildfly-client-config:jar:1.0.1.Final:compile + org.jboss.xnio:xnio-nio:jar:3.8.16.Final:runtime + org.jboss.threads:jboss-threads:jar:3.5.0.Final:compile + com.google.guava:guava:jar:32.0.0-jre:compile + com.google.guava:failureaccess:jar:1.0.1:compile + com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile + com.google.code.findbugs:jsr305:jar:3.0.2:compile + org.checkerframework:checker-qual:jar:3.33.0:compile + com.google.errorprone:error_prone_annotations:jar:2.18.0:compile + com.google.j2objc:j2objc-annotations:jar:2.8:compile + junit:junit:jar:4.13.1:test + org.hamcrest:hamcrest-core:jar:1.3:test + + "} + ); + }); +} + +/* +#[test] +fn descriptive_error_message() { + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/app-with-compile-error") + .expected_build_result(BuildResult::Failure), + |context| { + assert_contains_match!(context.build_output, indoc! {" + remote: \\[INFO\\] ------------------------------------------------------------------------ + remote: \\[INFO\\] BUILD FAILURE + remote: \\[INFO\\] ------------------------------------------------------------------------ + remote: \\[INFO\\] Total time: [0-9\\.]+ s + remote: \\[INFO\\] Finished at: [^ ]+ + remote: \\[INFO\\] ------------------------------------------------------------------------ + remote: \\[ERROR\\] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile \\(default-compile\\) on project app-with-compile-error: Compilation failure + remote: \\[ERROR\\] /tmp/build_[^ ]+/src/main/java/com/heroku/App.java:\\[5,28\\] ';' expected + remote: \\[ERROR\\] -> \\[Help 1\\] + remote: \\[ERROR\\] + remote: \\[ERROR\\] To see the full stack trace of the errors, re-run Maven with the -e switch. + remote: \\[ERROR\\] Re-run Maven using the -X switch to enable full debug logging. + remote: \\[ERROR\\] + remote: \\[ERROR\\] For more information about the errors and possible solutions, please read the following articles: + remote: \\[ERROR\\] \\[Help 1\\] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException + remote: + remote: ! ERROR: Failed to build app with Maven + remote: We're sorry this build is failing! If you can't find the issue in application code, + remote: please submit a ticket so we can help: https://help.heroku.com/ + remote: + remote: ! Push rejected, failed to compile Java app. + "}) + }, + ); +}*/ diff --git a/tests/polyglot.rs b/tests/polyglot.rs new file mode 100644 index 00000000..a519b826 --- /dev/null +++ b/tests/polyglot.rs @@ -0,0 +1,14 @@ +use rusty_hatchet::HerokuStack::Heroku24; +use rusty_hatchet::{BuildConfig, TestRunner, assert_contains, assert_not_contains}; + +#[test] +fn non_xml_pom() { + let config = BuildConfig::new( + Heroku24, + "test/spec/fixtures/repos/simple-http-service-groovy-polyglot", + ); + + TestRunner::default().build(config.clone(), |context| { + assert_contains!(context.build_output, "[INFO] BUILD SUCCESS"); + }); +} diff --git a/tests/settings_xml.rs b/tests/settings_xml.rs new file mode 100644 index 00000000..d2a926ec --- /dev/null +++ b/tests/settings_xml.rs @@ -0,0 +1,188 @@ +use indoc::{formatdoc, indoc}; +use rusty_hatchet::HerokuStack::Heroku24; +use rusty_hatchet::{BuildConfig, BuildResult, TestRunner, assert_contains, assert_not_contains}; +use std::path::Path; + +#[test] +fn settings_xml_url() { + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .env("MAVEN_SETTINGS_URL", SETTINGS_XML_URL), + |context| { + assert_contains!( + context.build_output, + &format!( + "[BUILDPACK INTEGRATION TEST - SETTINGS TEST VALUE] {SETTINGS_XML_URL_VALUE}" + ) + ); + }, + ); +} + +#[test] +fn settings_xml_url_failure() { + TestRunner::default().build(BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .env("MAVEN_SETTINGS_URL", SETTINGS_XML_URL_404) + .expected_build_result(BuildResult::Failure), |context| { + assert_contains!( + context.build_output, + indoc! {" + remote: -----> Executing Maven + remote: $ ./mvnw -DskipTests clean dependency:list install + remote: [ERROR] Error executing Maven. + remote: [ERROR] 1 problem was encountered while building the effective settings + remote: [FATAL] Non-parseable settings /tmp/codon/tmp/cache/.m2/settings.xml: only whitespace content allowed before start tag and not N (position: START_DOCUMENT seen N... @1:1) @ /tmp/codon/tmp/cache/.m2/settings.xml, line 1, column 1 + "} + ); + + assert_contains!( + context.build_output, + indoc! {" + remote: ! ERROR: Failed to build app with Maven + remote: We're sorry this build is failing! If you can't find the issue in application code, + remote: please submit a ticket so we can help: https://help.heroku.com/ + "} + ); + + assert_contains!(context.build_output, "remote: ! Push rejected, failed to compile Java app."); + }); +} + +#[test] +fn settings_xml_path() { + let settings_xml_filename = "forgreatjustice.xml"; + let settings_xml_test_value = "Take off every 'ZIG'!!"; + + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .env("MAVEN_SETTINGS_PATH", settings_xml_filename) + .app_dir_preprocessor(move |path| { + write_settings_xml(&path.join(settings_xml_filename), settings_xml_test_value); + }), + |context| { + assert_contains!( + context.build_output, + &format!( + "[BUILDPACK INTEGRATION TEST - SETTINGS TEST VALUE] {settings_xml_test_value}" + ) + ); + }, + ); +} + +#[test] +fn settings_xml_path_and_url() { + let settings_xml_filename = "zerowing.xml"; + let settings_xml_test_value = "We get signal."; + + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .env("MAVEN_SETTINGS_PATH", settings_xml_filename) + .env("MAVEN_SETTINGS_URL", SETTINGS_XML_URL) + .app_dir_preprocessor(move |path| { + write_settings_xml(&path.join(settings_xml_filename), settings_xml_test_value); + }), + |context| { + // MAVEN_SETTINGS_PATH should take precedence + assert_contains!( + context.build_output, + &format!( + "[BUILDPACK INTEGRATION TEST - SETTINGS TEST VALUE] {settings_xml_test_value}" + ) + ); + }, + ); +} + +#[test] +fn automatic_settings_xml() { + let settings_xml_filename = "settings.xml"; + let settings_xml_test_value = "Somebody set up us the bomb."; + + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .app_dir_preprocessor(move |path| { + write_settings_xml(&path.join(settings_xml_filename), settings_xml_test_value); + }), + |context| { + assert_contains!( + context.build_output, + &format!( + "[BUILDPACK INTEGRATION TEST - SETTINGS TEST VALUE] {settings_xml_test_value}" + ) + ); + }, + ); +} + +#[test] +fn settings_xml_path_and_settings_xml() { + let settings_xml_filename = "settings.xml"; + let settings_xml_test_value = "Somebody set up us the bomb."; + let zero_wing_filename = "zerowing.xml"; + let zero_wing_test_value = "How are you gentlemen !!"; + + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .env("MAVEN_SETTINGS_PATH", zero_wing_filename) + .app_dir_preprocessor(move |path| { + write_settings_xml(&path.join(settings_xml_filename), settings_xml_test_value); + write_settings_xml(&path.join(zero_wing_filename), zero_wing_test_value); + }), + |context| { + assert_contains!( + context.build_output, + &format!( + "[BUILDPACK INTEGRATION TEST - SETTINGS TEST VALUE] {zero_wing_test_value}" + ) + ); + }, + ); +} + +#[test] +fn settings_xml_url_and_settings_xml() { + let settings_xml_filename = "settings.xml"; + let settings_xml_test_value = "Somebody set up us the bomb."; + + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .env("MAVEN_SETTINGS_URL", SETTINGS_XML_URL) + .app_dir_preprocessor(move |path| { + write_settings_xml(&path.join(settings_xml_filename), settings_xml_test_value); + }), + |context| { + assert_contains!( + context.build_output, + &format!( + "[BUILDPACK INTEGRATION TEST - SETTINGS TEST VALUE] {SETTINGS_XML_URL_VALUE}" + ) + ); + }, + ); +} + +fn write_settings_xml(path: &Path, test_value: &str) { + std::fs::write( + path, + formatdoc! {" + + + + + true + + + {test_value} + + + + + ", test_value = test_value}, + ).unwrap(); +} + +const SETTINGS_XML_URL: &str = "https://gist.githubusercontent.com/Malax/d47323823a3d59249cbb5593c4f1b764/raw/83f196719d2c4d56aec6720964ba7d7c86b71727/download-settings.xml"; +const SETTINGS_XML_URL_VALUE: &str = "Main screen turn on."; +const SETTINGS_XML_URL_404: &str = "https://gist.githubusercontent.com/Malax/settings.xml"; diff --git a/tests/smoke.rs b/tests/smoke.rs new file mode 100644 index 00000000..ce986479 --- /dev/null +++ b/tests/smoke.rs @@ -0,0 +1,18 @@ +use rusty_hatchet::HerokuStack::Heroku24; +use rusty_hatchet::{BuildConfig, TestRunner, assert_contains}; + +#[test] +fn getting_started_app() { + TestRunner::default().build( + BuildConfig::new( + Heroku24, + "test/spec/fixtures/repos/github/java-getting-started", + ), + |context| { + assert_contains!( + context.http_request("/").unwrap(), + "Java Getting Started on Heroku" + ); + }, + ); +} diff --git a/tests/versions.rs b/tests/versions.rs new file mode 100644 index 00000000..2702dfcf --- /dev/null +++ b/tests/versions.rs @@ -0,0 +1,174 @@ +use indoc::formatdoc; +use rusty_hatchet::HerokuStack::Heroku24; +use rusty_hatchet::{BuildConfig, TestRunner, assert_contains, assert_not_contains}; +use std::fs::OpenOptions; +use std::path::Path; + +#[test] +fn use_maven_wrapper() { + TestRunner::default().build( + BuildConfig::new( + Heroku24, + "test/spec/fixtures/repos/github/simple-http-service", + ), + |context| { + assert_contains!(context.build_output, "$ ./mvnw"); + assert_contains!(context.build_output, &format!("[BUILDPACK INTEGRATION TEST - MAVEN VERSION] {SIMPLE_HTTP_SERVICE_MAVEN_WRAPPER_VERSION}")); + }, + ); +} + +#[test] +fn maven_wrapper_prioritization() { + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .app_dir_preprocessor(|path| { + set_java_property( + path.join("system.properties"), + "maven.version", + DEFAULT_MAVEN_VERSION, + ); + }), + |context| { + assert_not_contains!(context.build_output, "$ ./mvnw"); + + assert_contains!( + context.build_output, + &format!("remote: -----> Installing Maven {DEFAULT_MAVEN_VERSION}... done") + ); + + assert_contains!( + context.build_output, + &format!("[BUILDPACK INTEGRATION TEST - MAVEN VERSION] {DEFAULT_MAVEN_VERSION}") + ); + }, + ); +} + +#[test] +fn maven_wrapper_prioritization_with_unknown_version() { + TestRunner::default().build( + BuildConfig::new( + Heroku24, + "test/spec/fixtures/repos/simple-http-service", + ) + .app_dir_preprocessor(|path| { + set_java_property(path.join("system.properties"), "maven.version", UNKNOWN_MAVEN_VERSION); + }), + |context| { + assert_contains!( + context.build_output, + &formatdoc! {" + remote: -----> Installing Maven {unknown_version}... + remote: ! ERROR: Error, you have defined an unsupported Maven version in the system.properties file. + remote: The default supported version is {default_version} + ", unknown_version = UNKNOWN_MAVEN_VERSION, default_version = DEFAULT_MAVEN_VERSION} + ); + }, + ); +} + +#[test] +fn install_maven_when_no_wrapper() { + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .app_dir_preprocessor(|path| { + std::fs::remove_file(path.join("mvnw")).unwrap(); + }), + |context| { + assert_not_contains!(context.build_output, "$ ./mvnw"); + assert_contains!( + context.build_output, + &format!("remote: -----> Installing Maven {DEFAULT_MAVEN_VERSION}... done") + ); + assert_contains!( + context.build_output, + &format!("[BUILDPACK INTEGRATION TEST - MAVEN VERSION] {DEFAULT_MAVEN_VERSION}") + ); + }, + ); +} + +#[test] +fn install_maven_unknown_version() { + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .app_dir_preprocessor(|path| { + std::fs::remove_file(path.join("mvnw")).unwrap(); + set_java_property( + path.join("system.properties"), + "maven.version", + UNKNOWN_MAVEN_VERSION, + ); + }), + |context| { + assert_contains!( + context.build_output, + &formatdoc! {" + remote: -----> Installing Maven {unknown_version}... + remote: ! ERROR: Error, you have defined an unsupported Maven version in the system.properties file. + remote: The default supported version is {default_version} + ", unknown_version = UNKNOWN_MAVEN_VERSION, default_version = DEFAULT_MAVEN_VERSION} + ); + }, + ); +} + +#[test] +fn install_maven_default_version() { + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .app_dir_preprocessor(|path| { + std::fs::remove_file(path.join("mvnw")).unwrap(); + }), + |context| { + assert_not_contains!(context.build_output, "$ ./mvnw"); + assert_contains!( + context.build_output, + &format!("remote: -----> Installing Maven {DEFAULT_MAVEN_VERSION}... done") + ); + assert_contains!( + context.build_output, + &format!("[BUILDPACK INTEGRATION TEST - MAVEN VERSION] {DEFAULT_MAVEN_VERSION}") + ); + }, + ); +} + +#[test] +fn install_maven_configured_version() { + TestRunner::default().build( + BuildConfig::new(Heroku24, "test/spec/fixtures/repos/simple-http-service") + .app_dir_preprocessor(|path| { + std::fs::remove_file(path.join("mvnw")).unwrap(); + set_java_property(path.join("system.properties"), "maven.version", "3.9.4"); + }), + |context| { + assert_not_contains!(context.build_output, "$ ./mvnw"); + assert_contains!( + context.build_output, + "remote: -----> Installing Maven 3.9.4... done" + ); + assert_contains!( + context.build_output, + "[BUILDPACK INTEGRATION TEST - MAVEN VERSION] 3.9.4" + ); + }, + ); +} + +fn set_java_property(path: impl AsRef, key: &str, value: &str) { + let file = OpenOptions::new() + .read(true) + .write(true) + .open(path) + .unwrap(); + + let mut properties = java_properties::read(&file).unwrap(); + properties.insert(String::from(key), String::from(value)); + java_properties::write(&file, &properties).unwrap(); +} + +const DEFAULT_MAVEN_VERSION: &str = "3.9.4"; +const UNKNOWN_MAVEN_VERSION: &str = "1.0.0-unknown-version"; +const SIMPLE_HTTP_SERVICE_MAVEN_WRAPPER_VERSION: &str = "3.6.3";