Skip to content
Snippets Groups Projects
Commit d536e5d2 authored by Jerome Reybert's avatar Jerome Reybert
Browse files

test/: don't use temp file to store diff

parent f2617811
Branches
Tags
No related merge requests found
......@@ -8,7 +8,7 @@ Execute (Add file):
call Move_relative(+1)
call magit#stage_file()
call Cd_test()
call Git_diff('staged', 'bootstrap', '/tmp/addFile_bootstrap.test')
call Expect_diff(g:test_dir . 'addFile_bootstrap.expect', '/tmp/addFile_bootstrap.test')
let diff=Git_diff('staged', 'bootstrap')
call Expect_diff(g:test_dir . 'addFile_bootstrap.expect', diff)
Include: cleanup.inc
......@@ -9,21 +9,20 @@ function! Move_relative(nb_lines)
call cursor(line('.') + a:nb_lines, 0)
endfunction
function! Git_diff(state, file, output)
function! Git_diff(state, file)
let staged_flag = ( a:state == 'staged' ) ? ' --staged ' : ''
let diff_cmd="git diff --no-color --no-ext-diff --src-prefix='' --dst-prefix='' " .
\ staged_flag . " -- " . a:file .
\ " | \\grep -v \"^index [[:xdigit:]]\\{7\\}\\.\\.[[:xdigit:]]\\{7\\}\" > " .
\ a:output)
\ " | \\grep -v \"^index [[:xdigit:]]\\{7\\}\\.\\.[[:xdigit:]]\\{7\\}\""
let diff=system(diff_cmd)
if ( v:shell_error != 0 )
echoerr "git diff: " . diff
endif
return v:shell_error
return diff
endfunction
function! Expect_diff(gold_file, test_file)
let diff=system("diff " . a:gold_file . " " . a:test_file)
function! Expect_diff(gold_file, test_diff)
let diff=system("diff " . a:gold_file . " - ", a:test_diff)
if ( v:shell_error != 0 )
echoerr "diff: " . diff
endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment