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

Verify .NET runtime dependencies #50

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions spec/fixtures/basic_web_8.0/bin/test-runtime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -euo pipefail

# Check that all dynamically linked libraries exist in the run image
INSTALL_DIR="$(command -v dotnet)"
ldd_output=$(find "$(dirname "${INSTALL_DIR}")" -type f,l \( -name 'dotnet' -o -name '*.so*' \) -exec ldd '{}' +)
if grep 'not found' <<<"${ldd_output}" | sort --unique; then
echo "The above dynamically linked libraries were not found!"
exit 1
else
echo "All dynamically linked libraries were found."
fi
4 changes: 4 additions & 0 deletions spec/hatchet/buildpack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
remote: Procfile declares types -> \\(none\\)
remote: Default types for buildpack -> foo
REGEX

expect(app.run('bin/test-runtime.sh')).to match('All dynamically linked libraries were found.')
Copy link
Member

@edmorley edmorley Mar 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting app.run() doesn't check exit status by default, so if the success string match were ever removed, this would need to then assert against $?.exitstatus or $?.success?, per:
https://github.com/heroku/hatchet/?tab=readme-ov-file#build-versus-run-testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah so an earlier version actually did check the exit status as suggested in the Hatchet docs, but caused RuboCop to balk at the use of $? (rather than $CHILD_STATUS). I lazily ended up just verifying the success output string match as you noticed :)

I've added it back in this commit using the $CHILD_STATUS alias for $?, and preferring be_success + be_zero predicate matchers.

Perhaps I should also submit a PR to update the Hatchet docs/README/templates to prefer the more readable alias and predicate matchers instead? Seems this would involve updating at least:

expect($CHILD_STATUS.exitstatus).to be_zero
expect($CHILD_STATUS).to be_success
end
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require 'rspec/core'
require 'rspec/retry'
require 'hatchet'
require 'English'

FIXTURE_DIR = Pathname.new(__FILE__).parent.join('fixtures')

Expand Down
Loading