Vim script ট্র্যাকে টেস্টিং

Exercism-এ আপনার Vim script অনুশীলনীগুলো কীভাবে টেস্ট করবেন তা শিখুন


টেস্ট স্যুট চালানো এবং সেরা অনুশীলন নিশ্চিত করার জন্য এই ট্র্যাকটি দুটি টুল ব্যবহার করে:

  1. vader.vim
  2. vint

টেস্ট চালানো

  1. vader.vim ইনস্টল করুন।
  2. আপনার সমাধানটি খুলুন:
    $ vim exercise.vim
    
  3. এর গ্লোবাল ফাংশনগুলো Vim-এ পাওয়া যায়, সেজন্য বর্তমান ফাইলটি সোর্স করুন:
    :source %
    
  4. টেস্টগুলো চালান:
    :Vader exercise.vader
    

পাথ ভিন্ন হতে পারে।

উপরের ধাপগুলোর জন্য একটি সুবিধাজনক শর্টকাট চাইলে এটি আপনার vimrc-তে রাখুন:

function! s:exercism_tests()
  if expand('%:e') == 'vim'
    let testfile = printf('%s/%s.vader', expand('%:p:h'),
          \ tr(expand('%:p:h:t'), '-', '_'))
    if !filereadable(testfile)
      echoerr 'File does not exist: '. testfile
      return
    endif
    source %
    execute 'Vader' testfile
  else
    let sourcefile = printf('%s/%s.vim', expand('%:p:h'),
          \ tr(expand('%:p:h:t'), '-', '_'))
    if !filereadable(sourcefile)
      echoerr 'File does not exist: '. sourcefile
      return
    endif
    execute 'source' sourcefile
    Vader
  endif
endfunction

autocmd BufRead *.{vader,vim}
      \ command! -buffer Test call s:exercism_tests()

এরপর অনুশীলনীর ডিরেক্টরি থেকে যেকোনো .vim বা .vader ফাইল খুলে :Test কমান্ডটি চালান।

Vim ফাইল লিন্ট করা

  1. vint ইনস্টল করুন।
  2. সব Vim ফাইল রিকার্সিভভাবে লিন্ট করুন:
    $ vint .
    

Vim script ট্র্যাক সম্পর্কে আরও বিস্তারিত তথ্যের জন্য সহায়তা পৃষ্ঠা দেখুন।