From 9307a53c7bc30f9d17b6ab97e90d8a1b5fc313b2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 7 Aug 2024 06:53:05 +0800 Subject: [PATCH] vim-patch:9.1.0661: the zip plugin is not tested. (#29993) Problem: the zip plugin is not tested. Solution: include tests (Damien) closes: vim/vim#15411 https://github.com/vim/vim/commit/d7af21e746f3992c650caf6b76465880b96302b4 Co-authored-by: Damien <141588647+xrandomname@users.noreply.github.com> --- .github/workflows/test_windows.yml | 1 + test/old/testdir/samples/test.zip | Bin 0 -> 464 bytes test/old/testdir/test_zip_plugin.vim | 139 +++++++++++++++++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 test/old/testdir/samples/test.zip create mode 100644 test/old/testdir/test_zip_plugin.vim diff --git a/.github/workflows/test_windows.yml b/.github/workflows/test_windows.yml index d92993a08c..db7ad93f55 100644 --- a/.github/workflows/test_windows.yml +++ b/.github/workflows/test_windows.yml @@ -60,6 +60,7 @@ jobs: uses: msys2/setup-msys2@v2 with: update: true + install: unzip pacboy: >- make:p gcc:p diffutils:p release: false diff --git a/test/old/testdir/samples/test.zip b/test/old/testdir/samples/test.zip new file mode 100644 index 0000000000000000000000000000000000000000..6d34ac69928fa9b1a91e088ca468529b8e40f479 GIT binary patch literal 464 zcmWIWW@h1H0D(frzY!oBhFKY87$T}N3-m)nI2oA54lPRq;nE6j21b?_%nS@*0=ITf znD&&+A|j0tNd6l!e}(uD76t|e5axv$k(Qa0s#j7`0(QxR+~sK?jOLR3yi~3LZ$>6L zW?bHpfci{;;jJTx3H2N+#B*rI;WLVp0of>f1_nqtK|D&>I81LsjALYAU|7=F1Tzld dX;ubiEFKQ" + call assert_equal("X.zip", @%) + + "## Check ENTER on directory + :1|:/^$//dir/ + call assert_match('Please specify a file, not a directory', + \ execute("normal \")) + + "## Check ENTER on file + :1|:/^$//file/ + exe ":normal \" + call assert_match('zipfile://.*/X.zip::Xzip/file.txt', @%) + call assert_equal('one', getline(1)) + + "## Check editing file + if executable("zip") + s/one/two/ + call assert_equal("two", getline(1)) + w + bw|bw + e X.zip + + :1|:/^$//file/ + exe "normal \" + call assert_equal("two", getline(1)) + endif + + only + e X.zip + + "## Check extracting file + :1|:/^$//file/ + normal x + call assert_true(filereadable("Xzip/file.txt")) + call delete("Xzip", "rf") + + "## Check extracting directory + :1|:/^$//dir/ + call assert_match('Please specify a file, not a directory', execute("normal x")) + call assert_equal("X.zip", @%) + + "## Check "x" on header + :1 + normal x + call assert_equal("X.zip", @%) + bw + + "## Check opening zip when "unzip" program is missing + let save_zip_unzipcmd = g:zip_unzipcmd + let g:zip_unzipcmd = "/" + call assert_match('unzip not available on your system', execute("e X.zip")) + + "## Check when "unzip" don't work + if executable("false") + let g:zip_unzipcmd = "false" + call assert_match('X\.zip is not a zip file', execute("e X.zip")) + endif + bw + + let g:zip_unzipcmd = save_zip_unzipcmd + e X.zip + + "## Check opening file when "unzip" is missing + let g:zip_unzipcmd = "/" + call assert_match('sorry, your system doesn''t appear to have the / program', + \ execute("normal \")) + + bw|bw + let g:zip_unzipcmd = save_zip_unzipcmd + e X.zip + + "## Check :write when "zip" program is missing + :1|:/^$//file/ + exe "normal \Goanother\" + let save_zip_zipcmd = g:zip_zipcmd + let g:zip_zipcmd = "/" + call assert_match('sorry, your system doesn''t appear to have the / program', + \ execute("write")) + + "## Check when "zip" report failure + if executable("false") + let g:zip_zipcmd = "false" + call assert_match('sorry, unable to update .*/X.zip with Xzip/file.txt', + \ execute("write")) + endif + bw!|bw + + let g:zip_zipcmd = save_zip_zipcmd + + "## Check opening an no zipfile + call writefile(["qsdf"], "Xcorupt.zip", "D") + e! Xcorupt.zip + call assert_equal("qsdf", getline(1)) + + bw + + "## Check no existing zipfile + call assert_match('File not readable', execute("e Xnot_exists.zip")) + + bw + + let &shellslash = _sl + +endfunc