diff --git a/test/addDir.vader b/test/addDir.vader new file mode 100644 index 0000000000000000000000000000000000000000..75de58fb2c6215030d14210a1868c278302881b6 --- /dev/null +++ b/test/addDir.vader @@ -0,0 +1,69 @@ +Include: setup.inc + +Execute (Stage untracked directory closed): + call Cd_test_sub() + Magit + call Search_file('unstaged') + call magit#open_close_folding(0) + call Cursor_position() + call magit#stage_file() + call Cd_test() + let diff=Git_diff('staged') + call Expect_diff(g:test_script_dir . 'addDir/addDir_all_diff.expect', diff) + call Git_cmd("git reset") + +Execute (Stage untracked directory opened): + call Cd_test_sub() + Magit + call Search_file('unstaged') + call magit#open_close_folding(1) + call Cursor_position() + call magit#stage_file() + call Cd_test() + let diff=Git_diff('staged') + call Expect_diff(g:test_script_dir . 'addDir/addDir_all_diff.expect', diff) + call Git_cmd("git reset") + +Execute (Stage untracked hidden file): + call Cd_test_sub() + Magit + call Search_file('unstaged') + call magit#open_close_folding(1) + call Search_pattern(Get_filename() . '.hidden') + call Cursor_position() + call magit#stage_file() + call Cd_test() + let diff=Git_diff('staged') + call Expect_diff(g:test_script_dir . 'addDir/addDir_hidden_diff.expect', diff) + call Git_cmd("git reset") + +Execute (Stage untracked subdir file): + call Cd_test_sub() + Magit + call Search_file('unstaged') + call magit#open_close_folding(1) + call Search_pattern(Get_filename() . 'newsubdir') + call Cursor_position() + call magit#stage_file() + call Cd_test() + let diff=Git_diff('staged') + call Expect_diff(g:test_script_dir . 'addDir/addDir_subdir_diff.expect', diff) + call Git_cmd("git reset") + +Execute (Stage untracked subsubfile): + call Cd_test_sub() + Magit + call Search_file('unstaged') + call magit#open_close_folding(1) + call Search_pattern(Get_filename() . 'newsubdir') + call magit#open_close_folding(1) + call Search_pattern(Get_filename() . 'newsubdir/e') + call Cursor_position() + call magit#stage_file() + call Cd_test() + let diff=Git_diff('staged') + call Expect_diff(g:test_script_dir . 'addDir/addDir_subsubfile_diff.expect', diff) + call Git_cmd("git reset") + +Include: cleanup.inc + diff --git a/test/addDir/addDir_all_diff.expect b/test/addDir/addDir_all_diff.expect new file mode 100644 index 0000000000000000000000000000000000000000..1b81b0420aa2f6f76b7e4c04778b025450373c2a --- /dev/null +++ b/test/addDir/addDir_all_diff.expect @@ -0,0 +1,42 @@ +diff --git newdir/.hidden newdir/.hidden +new file mode 100644 +--- /dev/null ++++ newdir/.hidden +@@ -0,0 +1 @@ ++this is an hidden file +diff --git newdir/a newdir/a +new file mode 100644 +--- /dev/null ++++ newdir/a +@@ -0,0 +1 @@ ++a +diff --git newdir/b newdir/b +new file mode 100644 +--- /dev/null ++++ newdir/b +@@ -0,0 +1 @@ ++b +diff --git newdir/c newdir/c +new file mode 100644 +--- /dev/null ++++ newdir/c +@@ -0,0 +1 @@ ++c +diff --git newdir/newsubdir/d newdir/newsubdir/d +new file mode 100644 +--- /dev/null ++++ newdir/newsubdir/d +@@ -0,0 +1 @@ ++d +diff --git newdir/newsubdir/e newdir/newsubdir/e +new file mode 100644 +--- /dev/null ++++ newdir/newsubdir/e +@@ -0,0 +1 @@ ++e +diff --git newdir/newsubdir/f newdir/newsubdir/f +new file mode 100644 +--- /dev/null ++++ newdir/newsubdir/f +@@ -0,0 +1 @@ ++f diff --git a/test/addDir/addDir_hidden_diff.expect b/test/addDir/addDir_hidden_diff.expect new file mode 100644 index 0000000000000000000000000000000000000000..5168c5acc7adf93e0c567b4d5ad2a5eb3a330fff --- /dev/null +++ b/test/addDir/addDir_hidden_diff.expect @@ -0,0 +1,6 @@ +diff --git newdir/.hidden newdir/.hidden +new file mode 100644 +--- /dev/null ++++ newdir/.hidden +@@ -0,0 +1 @@ ++this is an hidden file diff --git a/test/addDir/addDir_subdir_diff.expect b/test/addDir/addDir_subdir_diff.expect new file mode 100644 index 0000000000000000000000000000000000000000..f44ecbd9274aceda498448090e8dae2de13f9331 --- /dev/null +++ b/test/addDir/addDir_subdir_diff.expect @@ -0,0 +1,18 @@ +diff --git newdir/newsubdir/d newdir/newsubdir/d +new file mode 100644 +--- /dev/null ++++ newdir/newsubdir/d +@@ -0,0 +1 @@ ++d +diff --git newdir/newsubdir/e newdir/newsubdir/e +new file mode 100644 +--- /dev/null ++++ newdir/newsubdir/e +@@ -0,0 +1 @@ ++e +diff --git newdir/newsubdir/f newdir/newsubdir/f +new file mode 100644 +--- /dev/null ++++ newdir/newsubdir/f +@@ -0,0 +1 @@ ++f diff --git a/test/addDir/addDir_subsubfile_diff.expect b/test/addDir/addDir_subsubfile_diff.expect new file mode 100644 index 0000000000000000000000000000000000000000..a62cdbdeab4b6e17b3fbdde06028070e6fba1d30 --- /dev/null +++ b/test/addDir/addDir_subsubfile_diff.expect @@ -0,0 +1,6 @@ +diff --git newdir/newsubdir/e newdir/newsubdir/e +new file mode 100644 +--- /dev/null ++++ newdir/newsubdir/e +@@ -0,0 +1 @@ ++e diff --git a/test/run.sh b/test/run.sh index 751d8ca6b29936e0892b3621bc87d709832c9d66..2648c2007832092e05b65927e576d784002ffcec 100755 --- a/test/run.sh +++ b/test/run.sh @@ -26,7 +26,7 @@ fi pushd $TEST_PATH git config --local user.email 'tester@vimagit.org' git config --local user.name 'vimagit tester' -export TEST_HEAD_SHA1='dcacf08' +export TEST_HEAD_SHA1='bb86d5f' git submodule update git show $TEST_HEAD_SHA1 --stat git reset $TEST_HEAD_SHA1~1 && git status --porcelain && git reset --hard $TEST_HEAD_SHA1 diff --git a/test/test.config b/test/test.config index f99a8de32f6a1456cd85cf635928151bba72e028..02f9a295d3202680bccfb7aed45de834077c19c4 100644 --- a/test/test.config +++ b/test/test.config @@ -5,4 +5,5 @@ declare -A test_scripts=( [addSelect.vader]='books/models.py' [renameFile.vader]='manage.py|manage\ with\ spaces.py;djooks/settings\ with\ spaces.py|djooks/settings_without_spaces.py' [ignoreFile.vader]='bootstrap' + [addDir.vader]='newdir\/' ) diff --git a/test/utils.vim b/test/utils.vim index 4410147282b38803d41971f46db5ae03680ef210..9bca69a1461c72dd3d38efb52d53f0b9d2897ecb 100644 --- a/test/utils.vim +++ b/test/utils.vim @@ -77,10 +77,16 @@ function! Git_add_quotes(filename) endfunction " helper function to get the diff of a file, in staged or unstaged mode -function! Git_diff(state, file) +function! Git_diff(state, ...) let staged_flag = ( a:state == 'staged' ) ? ' --staged ' : '' + if ( a:0 == 1 ) + let file = " -- " . Git_add_quotes(a:file) + else + let file = "" + endif + let diff_cmd="git diff --no-color --no-ext-diff --src-prefix='' --dst-prefix='' " . - \ staged_flag . " -- " . Git_add_quotes(a:file) . + \ staged_flag . file . \ " | \\grep -v " . g:index_regex return Git_cmd(diff_cmd) endfunction