From f720499337bb3913ab332a305eaa7f9e74bc2133 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Wed, 17 Oct 2018 10:43:30 +1000 Subject: [PATCH] gem: fix tests to work on newer Fedora hosts (#47158) --- test/integration/targets/gem/tasks/main.yml | 89 ++++++++++++++++----- 1 file changed, 68 insertions(+), 21 deletions(-) diff --git a/test/integration/targets/gem/tasks/main.yml b/test/integration/targets/gem/tasks/main.yml index 924daa89301..555701ff2f2 100644 --- a/test/integration/targets/gem/tasks/main.yml +++ b/test/integration/targets/gem/tasks/main.yml @@ -37,33 +37,80 @@ name: gist state: present register: install_gem_result + ignore_errors: yes -- name: List gems - command: gem list - register: current_gems +# when running as root on Fedora, '--install-dir' is set in the os defaults which is +# incompatible with '--user-install', we ignore this error for this case only +- name: fail if failed to install gem + fail: + msg: "failed to install gem: {{ install_gem_result.msg }}" + when: + - install_gem_result is failed + - not (ansible_user_uid == 0 and "User --install-dir or --user-install but not both" not in install_gem_result.msg) -- name: Ensure gem was installed - assert: - that: - - install_gem_result is changed - - current_gems.stdout is search('gist\s+\([0-9.]+\)') +- block: + - name: List gems + command: gem list + register: current_gems -- name: Remove a gem - gem: - name: gist - state: absent - register: remove_gem_results + - name: Ensure gem was installed + assert: + that: + - install_gem_result is changed + - current_gems.stdout is search('gist\s+\([0-9.]+\)') -- name: List gems - command: gem list - register: current_gems + - name: Remove a gem + gem: + name: gist + state: absent + register: remove_gem_results -- name: Verify gem is not installed - assert: - that: - - remove_gem_results is changed - - current_gems.stdout is not search('gist\s+\([0-9.]+\)') + - name: List gems + command: gem list + register: current_gems + - name: Verify gem is not installed + assert: + that: + - remove_gem_results is changed + - current_gems.stdout is not search('gist\s+\([0-9.]+\)') + when: not install_gem_result is failed + +# install gem in --no-user-install +- block: + - name: Install a gem with --no-user-install + gem: + name: gist + state: present + user_install: no + register: install_gem_result + + - name: List gems + command: gem list + register: current_gems + + - name: Ensure gem was installed + assert: + that: + - install_gem_result is changed + - current_gems.stdout is search('gist\s+\([0-9.]+\)') + + - name: Remove a gem + gem: + name: gist + state: absent + register: remove_gem_results + + - name: List gems + command: gem list + register: current_gems + + - name: Verify gem is not installed + assert: + that: + - remove_gem_results is changed + - current_gems.stdout is not search('gist\s+\([0-9.]+\)') + when: ansible_user_uid == 0 # Check cutom gem directory - name: Install gem in a custom directory with incorrect options