diff --git a/test/Dockerfile b/test/Dockerfile index 9638acd..de236cd 100644 --- a/test/Dockerfile +++ b/test/Dockerfile @@ -43,6 +43,10 @@ COPY --chown=test:test conf.d $TEST_HOME/.config/fish/conf.d/ COPY --chown=test:test functions $TEST_HOME/.config/fish/functions/ RUN ls -R $TEST_HOME/.config/fish/ +# Signal we're safely running in a container; +# we abort the tests to avoid breaking the host system! +ENV RUNNING_IN_CONTAINER=yessir + # Run tests COPY test ./ ENTRYPOINT ["cucumber"] diff --git a/test/features/support/hooks.rb b/test/features/support/hooks.rb index d26980e..3997193 100644 --- a/test/features/support/hooks.rb +++ b/test/features/support/hooks.rb @@ -2,6 +2,10 @@ require_relative '../step_definitions/setup' require_relative '../step_definitions/corner_cases.rb' BeforeAll do + if ENV.fetch('RUNNING_IN_CONTAINER', false) != 'yessir' + Kernel.abort("We don't seem to be running in a container; aborting for safety!") + end + run_bash_command('sdk update') end @@ -12,7 +16,6 @@ After do |scenario| _restore_install end -# Uninstall all SDKMAN! candidates AfterAll do Dir["#{ENV['HOME']}/.sdkman/candidates/*/*"].each do |candidate_dir| _uninstall_candidate_version(candidate_dir)