#!/usr/bin/ruby # $URL: http://localhost:8008/svn/Research/CygwinAutoexeExpansionProblem/Test_ExeAutoExpand.rb $ # $Revision: 74 $ # $Date: 2016-09-02 14:49:50 -0400 (Fri, 02 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(rm -rf testAutoExeExpansion*) %x(mkdir -p testAutoExeExpansion) %x(mkdir -p testAutoExeExpansion/test) %x(touch testAutoExeExpansion/test.exe) %x(touch testAutoExeExpansion/test/test.exe) end # Do common stuff to wrap up tests. def teardown 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 zip/unzip with exe file in archive first, exclude problematic directory workaround # This causes problems. def test_unzipExeFirstExclude %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 -x testAutoExeExpansion/test/ ) 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_findrmr %x(find testAutoExeExpansion -path testAutoExeExpansion/test -type d -exec rm -r {}/ \\;) assert_equal(0, $?.exitstatus, "find failed!") end # Check that find can locate and remove directory with co-located exe file # This causes problems. def test_findrmdir %x(find testAutoExeExpansion -path testAutoExeExpansion/test -type d -exec rmdir {}/ \\;) assert_equal(0, $?.exitstatus, "find failed!") end end