From 97f97339f7c2b623cc86c7a6608ecb429bf39745 Mon Sep 17 00:00:00 2001 From: Matt Davis Date: Fri, 16 Nov 2018 11:23:53 -0800 Subject: [PATCH] re-enable batch tests for win_script (#48822) * skipped on Server 2008 since batch interpreter is busted under UTF8 codepage * see https://github.com/ansible/ansible/issues/21915 for more details --- .../targets/win_script/files/fail.bat | 1 + .../targets/win_script/tasks/main.yml | 78 ++++++++++++------- 2 files changed, 49 insertions(+), 30 deletions(-) create mode 100644 test/integration/targets/win_script/files/fail.bat diff --git a/test/integration/targets/win_script/files/fail.bat b/test/integration/targets/win_script/files/fail.bat new file mode 100644 index 00000000000..02562a8a7fb --- /dev/null +++ b/test/integration/targets/win_script/files/fail.bat @@ -0,0 +1 @@ +bang-run-a-thing-that-doesnt-exist diff --git a/test/integration/targets/win_script/tasks/main.yml b/test/integration/targets/win_script/tasks/main.yml index bba771ba78d..0134f12d508 100644 --- a/test/integration/targets/win_script/tasks/main.yml +++ b/test/integration/targets/win_script/tasks/main.yml @@ -16,6 +16,10 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . +- name: run setup to allow skipping OS-specific tests + setup: + gather_subset: min + - name: get tempdir path raw: $env:TEMP register: tempdir @@ -178,36 +182,50 @@ - "test_script_removes_file_again_result is not changed" - "test_script_removes_file_again_result is skipped" -# TODO: these tests fail on 2008 (not even R2) with no output. It's related to the default codepage being UTF8- if we force it back to 437, it works fine. -# Need to figure out a sane place to do that under the new exec wrapper. -#- name: run simple batch file -# script: test_script.bat -# register: test_batch_result -# -#- name: check that batch file ran -# assert: -# that: -# - "test_batch_result.rc == 0" -# - "test_batch_result.stdout" -# - "'batch' in test_batch_result.stdout" -# - "not test_batch_result.stderr" -# - "test_batch_result is not failed" -# - "test_batch_result is changed" - - -#- name: run simple batch file with .cmd extension -# script: test_script.cmd -# register: test_cmd_result -# -#- name: check that batch file with .cmd extension ran -# assert: -# that: -# - "test_cmd_result.rc == 0" -# - "test_cmd_result.stdout" -# - "'cmd extension' in test_cmd_result.stdout" -# - "not test_cmd_result.stderr" -# - "test_cmd_result is not failed" -# - "test_cmd_result is changed" +- name: skip batch tests on 6.0 (UTF8 codepage prevents it from working, see https://github.com/ansible/ansible/issues/21915) + block: + - name: run simple batch file + script: test_script.bat + register: test_batch_result + + - name: check that batch file ran + assert: + that: + - "test_batch_result.rc == 0" + - "test_batch_result.stdout" + - "'batch' in test_batch_result.stdout" + - "not test_batch_result.stderr" + - "test_batch_result is not failed" + - "test_batch_result is changed" + + - name: run simple batch file with .cmd extension + script: test_script.cmd + register: test_cmd_result + + - name: check that batch file with .cmd extension ran + assert: + that: + - "test_cmd_result.rc == 0" + - "test_cmd_result.stdout" + - "'cmd extension' in test_cmd_result.stdout" + - "not test_cmd_result.stderr" + - "test_cmd_result is not failed" + - "test_cmd_result is changed" + + - name: run simple batch file with .bat extension that fails + script: fail.bat + ignore_errors: true + register: test_batch_result + + - name: check that batch file with .bat extension reported failure + assert: + that: + - test_batch_result.rc == 1 + - test_batch_result.stdout + - test_batch_result.stderr + - test_batch_result is failed + - test_batch_result is changed + when: not ansible_distribution_version.startswith('6.0') - name: run test script that takes a boolean parameter script: test_script_bool.ps1 $false # use false as that can pick up more errors