SlideShare una empresa de Scribd logo
1 de 15
Descargar para leer sin conexión
Emacsとテスト
shiba_yu36
プログラムを書く時は
テストが必須
Emacsでテストを
簡単に実行したい
普通にテスト実行する
(defun run-perl-test ()
"test実行します"
(interactive)
(compile
(format "prove -v %s"
(buffer-file-name (current-buffer)))))
デモ
問題
• 1ファイルにテスト増えてくると全部実
行するの辛い

• なんか絞れるんだったらやりたい
PerlでTest::Classのメソッド単位で実行する
(defun run-perl-method-test ()
(interactive)
(let (
(command compile-command)
(test-method nil))
(save-excursion
(when (or
(re-search-backward "bsubs+([_[:alpha:]]+)s*:s*Test" nil t)
(re-search-forward "bsubs+([_[:alpha:]]+)s*:s*Test" nil t))
(setq test-method (match-string 1))))
(if test-method
(compile
(format
"cd %s; TEST_METHOD=%s perl -M'Project::Libs lib_dirs => [qw(modules/*/lib
local/lib/perl5)]' %s"
(replace-regexp-in-string
"n+$" ""
(shell-command-to-string "git rev-parse --show-cdup"))
test-method
(buffer-file-name (current-buffer))))
(compile
(format
"cd %s; perl -M'Project::Libs lib_dirs => [qw(modules/*/lib local/lib/
perl5)]' %s"
(replace-regexp-in-string
"n+$" "" (shell-command-to-string "git rev-parse --show-cdup"))
(buffer-file-name (current-buffer)))))))
デモ
やっていること
• emacsで現在ファイル名、Test::Class
のメソッド名を取得

• proveのTEST_METHODを指定して
compileで実行
やっていること
• (buffer-file-name (current-buffer))
• 現在ファイルの絶対パス取る
やっていること
• save-excursion + re-searchbackword + match-string

• 現在状態をセーブした状態で正規表
現検索

• Test::Classのメソッド名とっている
やっていること
• (compile )
• compileでコマンド実行
• quick-runとか使っても良い
その他の言語??
• たぶんrubyとか他でも正規表現でテス
トの範囲を見つけられれば出来ます

• 頑張ろう
終わりです

Más contenido relacionado

Destacado (11)

事業成長にコミットするエンジニア組織への道のり
事業成長にコミットするエンジニア組織への道のり事業成長にコミットするエンジニア組織への道のり
事業成長にコミットするエンジニア組織への道のり
 
Hatena blogdevelopmentflow
Hatena blogdevelopmentflowHatena blogdevelopmentflow
Hatena blogdevelopmentflow
 
A Reintroduction To Ruby M17 N
A Reintroduction To Ruby M17 NA Reintroduction To Ruby M17 N
A Reintroduction To Ruby M17 N
 
tofu - COOKPAD's image system
tofu - COOKPAD's image systemtofu - COOKPAD's image system
tofu - COOKPAD's image system
 
Japanese Rubyists you have not met yet
Japanese Rubyists you have not met yetJapanese Rubyists you have not met yet
Japanese Rubyists you have not met yet
 
How to Begin to Develop Ruby Core
How to Begin to Develop Ruby CoreHow to Begin to Develop Ruby Core
How to Begin to Develop Ruby Core
 
Practical ngx_mruby
Practical ngx_mrubyPractical ngx_mruby
Practical ngx_mruby
 
Ruby Kaja のご提案
Ruby Kaja のご提案Ruby Kaja のご提案
Ruby Kaja のご提案
 
CloudTrail でログとれ〜る
CloudTrail でログとれ〜るCloudTrail でログとれ〜る
CloudTrail でログとれ〜る
 
Inspection of CloudML Hyper Parameter Tuning
Inspection of CloudML Hyper Parameter TuningInspection of CloudML Hyper Parameter Tuning
Inspection of CloudML Hyper Parameter Tuning
 
Ruby 1.9.3 and development of Ruby
Ruby 1.9.3 and development of RubyRuby 1.9.3 and development of Ruby
Ruby 1.9.3 and development of Ruby
 

Similar a 131026 kansai-emacs (9)

最近の単体テスト
最近の単体テスト最近の単体テスト
最近の単体テスト
 
あんなテスト、こんなテスト(this and that about testing)
あんなテスト、こんなテスト(this and that about testing)あんなテスト、こんなテスト(this and that about testing)
あんなテスト、こんなテスト(this and that about testing)
 
pecl-AOPの紹介
pecl-AOPの紹介pecl-AOPの紹介
pecl-AOPの紹介
 
MoteMote Compiler Plugin
MoteMote Compiler PluginMoteMote Compiler Plugin
MoteMote Compiler Plugin
 
EC-CUBE + PHPUnit で 実践テスト駆動開発
EC-CUBE + PHPUnit で 実践テスト駆動開発EC-CUBE + PHPUnit で 実践テスト駆動開発
EC-CUBE + PHPUnit で 実践テスト駆動開発
 
Testman
TestmanTestman
Testman
 
JavaScriptクイックスタート
JavaScriptクイックスタートJavaScriptクイックスタート
JavaScriptクイックスタート
 
ソフトウェア工学2023 11 テスト
ソフトウェア工学2023 11 テストソフトウェア工学2023 11 テスト
ソフトウェア工学2023 11 テスト
 
Ruby初級者向けレッスン 第46回 ─── Test::Unit
Ruby初級者向けレッスン 第46回 ─── Test::UnitRuby初級者向けレッスン 第46回 ─── Test::Unit
Ruby初級者向けレッスン 第46回 ─── Test::Unit
 

Más de Yuki Shibazaki (10)

130713 kyotopm-lt
130713 kyotopm-lt130713 kyotopm-lt
130713 kyotopm-lt
 
130427 kansai-emacs-github
130427 kansai-emacs-github130427 kansai-emacs-github
130427 kansai-emacs-github
 
130412 kayac-cinnamon
130412 kayac-cinnamon130412 kayac-cinnamon
130412 kayac-cinnamon
 
Cinnamon - simple deploy tool
Cinnamon - simple deploy toolCinnamon - simple deploy tool
Cinnamon - simple deploy tool
 
130207 kyotorb
130207 kyotorb130207 kyotorb
130207 kyotorb
 
121221社内lt
121221社内lt121221社内lt
121221社内lt
 
120225perl入学式02自己紹介
120225perl入学式02自己紹介120225perl入学式02自己紹介
120225perl入学式02自己紹介
 
120225perl入学式02
120225perl入学式02120225perl入学式02
120225perl入学式02
 
没入コミュニケーションに利用する3次元仮想キャラクタの半自動生成
没入コミュニケーションに利用する3次元仮想キャラクタの半自動生成没入コミュニケーションに利用する3次元仮想キャラクタの半自動生成
没入コミュニケーションに利用する3次元仮想キャラクタの半自動生成
 
テストデータどうしてますか?
テストデータどうしてますか?テストデータどうしてますか?
テストデータどうしてますか?
 

131026 kansai-emacs