I’m having an issue where I need to source paths that depend on the stage_dir being the root dir in my plugin test. Wondering how I can access stage_dir from the env or other means while in the plugin tests context, but outside of the actual test code?
name: ruby-hello
version: 0.1
summary: Test ruby
description: |
Snap to test ruby compiled correctly, exists, and env vars are sourced correctly
grade: devmode
confinement: devel
parts:
ruby-hello:
plugin: ruby
source: .
stage:
- bin
- lib
install: |
cp ./ruby-hello $SNAPCRAFT_PART_INSTALL/bin/ruby-hello
dump:
plugin: dump
source: .
My ruby-hello script errors out because it cannot find and successfully execute ruby without knowing RUBYPATH and RUBYLIB. How can I define RUBYPATH and RUBYLIB when they depend on a root of stage_dir, and there is no way for me to access stage_dir from outside of the python plugin test code?
Ah! Yeah trying to run the ruby binary straight out of stage with no environment setup will definitely not work. You need the environment generated by your plugin, but that doesn’t take effect until the prime step, and it’ll still depend on $SNAP being defined, etc. While this test is excellent, I suggest you instead write it as a snap test, in snaps_tests/. That allows you to run the resulting snap directly.
@elopio does that sound okay? I know you’re a little concerned about the size of the snap tests, please throw your opinion in here if you have a better suggestion.
sounds correct. I’m concerned about the snaps tests that don’t have a clear focus on what they are testing, but I think we should install and execute at least one snap for each of our plugins.