#!/usr/bin/ruby # $URL: http://localhost:8008/svn/Research/CygwinAutoexeExpansionProblem/Test_ExeAutoExpand.rb $ # $Revision: 73 $ # $Date: 2016-09-01 11:42:52 -0400 (Thu, 01 Sep 2016) $ # $Author: stephen_a $ require 'minitest/autorun' require 'fileutils' # Lots of straight-forward tests, success path only. class Test_ExeAutoExpand < Minitest::Test # Prepare common stuff for test execution. def setup # Create a hierarchy like this: # testAutoExeExpansion # | # - test.exe # + test/ # | # - test.exe # %x(mkdir -p testAutoExeExpansion) %x(mkdir -p testAutoExeExpansion/test) %x(cp -p /usr/bin/ls.exe testAutoExeExpansion/test.exe) %x(cp -p /usr/bin/ls.exe testAutoExeExpansion/test/test.exe) %x(rm -f testAutoExeExpansion.zip) end # Do common stuff to wrap up tests. def teardown %x(rm -rf testAutoExeExpansion*) end # Check that zip/unzip with default ordering works # The default ordering puts directory first and seems # to cause no problems. def test_unzipDefault %x(zip -r testAutoExeExpansion.zip testAutoExeExpansion) assert_equal(0, $?.exitstatus, "zip failed!") %x(rm -r testAutoExeExpansion/) %x(unzip -ouq testAutoExeExpansion.zip) assert_equal(0, $?.exitstatus, "unzip failed!") end # Check that zip/unzip with exe file in archive first # This causes problems. def test_unzipExeFirst %x(zip testAutoExeExpansion.zip testAutoExeExpansion/test.exe) assert_equal(0, $?.exitstatus, "zip1 failed!") %x(zip -r testAutoExeExpansion.zip testAutoExeExpansion/test/) assert_equal(0, $?.exitstatus, "zip2 failed!") %x(rm -r testAutoExeExpansion/) %x(unzip -ouq testAutoExeExpansion.zip) assert_equal(0, $?.exitstatus, "unzip failed!") end # Check that find can locate and remove directory with co-located exe file # This causes problems. def test_findExeDIR %x(find testAutoExeExpansion -type d -path testAutoExeExpansion/test -exec rm -rf {} \\;) assert_equal(0, $?.exitstatus, "find failed!") end end