Mon 17 September, 2007

“ Who chose this face for me? ”
Stephen Dedalus
add to del.icio.us. look up in del.icio.us.
add to furl
表现形式
因为C++不支持reflection,所以,必须要做一些额外的工作,让框架知道相关内容的存在。CppUnit的做法是用宏进行注册。这种做法要求我们每添加一个测试,就要考虑用相应的宏进行注册,这种做法很繁琐,最大的问题在于由于疏忽而遗漏,这种靠人工保证的东西不可靠。在这点上,CxxTest做得要好一些,有一个专门的脚本做这件事。通过这个脚本扫描这个自己编写的文件,生成一些新的文件,完成这个工作。从代码的表现力和可靠度来说,要好得多。唯一的问题是引入了一个脚本,而且这个脚本一般是由某些动态语言写成的(目前的CxxTest有Perl和Python的脚本),从而引入了对这种语言的依赖。不过,由于C++语言本身的限制,从接口的角度来看,这种做法已经很不错了。
语法
有一种C++的单元测试框架叫TUT,Template Unit Test的缩写。顾名思义,它是用模板完成的(其实,CppUnit和CxxTest都有模板的部分)。随着C++编译器的进步,在大多数情况下,模板都是可以顺利通过编译的。但是,不要忘了,还有一种环境叫嵌入式,那里的编译器基本上还是很原始的,模板并不见得能够顺利的通过编译。
此外,模板还会带来另外一个问题,编译时间的增长,相信有过模板编程经验的人都会对此深有体会。编译时间增长意味着什么?我们接下来讨论。
编译时间
有一种敏捷实践叫做测试驱动开发(Test Driven Development)。测试驱动开发的基础是单元测试。测试驱动开发希望达成的一个目标是快速反馈,所以,站在C++语言的角度,如果执行时间受限于代码本身无法缩短,那么我们希望编译时间尽可能短,这样,才不会把生命都浪费在等待代码编译上。
除了刚才提到的模板问题之外,CppUnit会把所有测试编译生成一个可执行文件,这意味着什么?几乎修改任何一个文件都会造成这个文件的重新生成。随着目标文件的增加,这个过程时间就会增长。相对于修改范围(可能只是某一个文件),还是显得有些长了。为什么Java语言不会存在这种现象?因为Java是动态连接的,所以,Java生成.class就结束了。对应到C++上,这只是完成了目标文件的生成,而在C++我们不得不再进一步生成可执行文件。从道理上,CxxTest可以为不同的测试文件生成不同的可执行文件,不过这么做又少了总体的过程,统计起来又显得心有余力不足了,而且通常不会这么做。
个人而言,对这几个单元测试框架都不是非常了解,如果前面的讨论存在谬误,欢迎有识之士指出。
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furlSun 16 September, 2007

For a while, the patch queue was getting badly out of hand. The flood of new entries was simply too great to be reasonably managed by a small group of people. Too much got stuff got stale and their creators got disillusioned, understandably so. But for a while now, we’ve been running with a new policy on patches, which seems to be working a lot better for those who’ve been following it.
But I’m sensing that a fair number of people are not aware of those changes in policy, so I thought best to bring them up again here.
Step 1: Raise the barriers of quality
Part of the reason that the original patch queue got out of hand was due to the large number of patches coming in that lacked essential qualities of a good patch. They were either missing a good rationale (why am I doing this? what’s the benefits?), good test cases, or didn’t update the relevant documentation. To apply such a patch meant that this work had to be shouldered by someone else, usually the guy who wanted to apply the patch.
Now the barriers of quality are more apparent. Your patch will simply not be considered for inclusion before it has all those elements. It’ll live with the “unverified” keyword until you or someone else that cares especially deeply about the patch (like someone else having the same problem) gets the quality up to par. Then the patch moves on to step 2.
Step 2: Get the community engaged to review your patch
The last step before your patch is ready to be put in the queue for inclusion is to get community support round up. We now require that three different people must review your patch, apply it, run the tests, read your documentation, and like what it does and how it’s implemented. When they do, they’ll make a comment on the ticket with a “+1”.
Get three such +1s and you can tag your patch with the “verified” keyword. That’ll make the patch appear in Report #12: Verified Patches, which is a bell telling the core team that you patch is baked and ready to be included (barring a final review).
The core team is trying to keep report #12 empty at all times. There shouldn’t be a big lag time between getting to “verified” and getting a final review of your patch, which will either send it back to unverified (because the implementation is deemed in need of work or because there’s some fundemental disagreement over whether or how this patch goes about its business) or it’ll be applied and available in edge.
So if you have a patch that you still care about sitting in the queue, dust it off, and put it through these two simple steps and you’ll be back on the road to glory. There are still no guarantees that your patch will receive immediate attention, but so far we’ve managed to keep report #12 moving very nicely. It’s all empty as of today!
The front page of http://dev.rubyonrails.org has been updated to reflect this policy.
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furlSat 15 September, 2007

Tomorrow I’ll fly to Berlin to attend RailsConf Europe 2007. There will be no mail, IRC and can’t live blog. But I wont be angry at non-working or darn expensive WLANs, either.
I have a hipster PDA with me, and an (albeit digital) camera, so don’t feel too safe.
If you’d like to meet me, feel free to contact
me by mobile or txt (I will read,
but not reply to tweets for chneukirchen).
I’d like to organize a BoF or similar for people interested in Rack and running Rails together with Rack. Catch me if you are curious.
chris blogs and Anarchaia will resume publishing on Friday, September 21.
Have a good time.
NP: Bob Dylan—4th Time Around
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
技术信息:构建工具buildr可能出现的错误信息
- 构建文件Rakefile或者buildfile里面没有定义变量repositories及其值
具体错误信息实例E:\work_jruby\buildr-jruby>rake -f Rakefile
(in E:/work_jruby/buildr-jruby)
"E:/work_jruby/buildr-jruby"
Downloading org.apache.ant:ant:jar:1.7.0
rake aborted!
No remote repositories defined!
E:/work_jruby/buildr-jruby/rakefile:14
(See full trace by running task with --trace) - 构建文件Rakefile或者buildfile里面没有在开始时使用方法require 'buildr'
具体错误信息实例E:\work_jruby\buildr-jruby>rake -T
(in E:/work_jruby/buildr-jruby)
rake aborted!
undefined local variable or method `repositories' for main:Object
E:/work_jruby/buildr-jruby/rakefile:11
(See full trace by running task with --trace)
add to del.icio.us. look up in del.icio.us.
add to furlFri 14 September, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furlThu 13 September, 2007

add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
“ I want to get a cat so I can call it Kitty Couric. ”
Sarah Chapin
add to del.icio.us. look up in del.icio.us.
add to furlWed 12 September, 2007

- An excellent add-in for VS for copying source code formatted as HTML
It even gets the background colors right. The only thing to really ask for is support for changing the tab stops for space-indented source code.
add to del.icio.us. look up in del.icio.us.
add to furl
2. The most private or secret parts; recesses: the penetralia of the soul.
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl
For all sorts of really wonderful reasons, I will not be prepared to give a proper Haskell presentation at upcoming Desert Code Camp. After speaking with Lorin, we agreed that I’ll do a Haskell thing as part of the ad-hoc BarCamp sessions that will be running throughout Code Camp.
Since my original Haskell talk was slated for 9:15 Saturday morning, that’s when I’ll be in the BarCamp section.
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furlTue 11 September, 2007

- A PowerShell console written in WPF
Hmmm ... wonder what this could mean for IronRuby??? :) - A nice discussion of nonce salts, passwords and "rainbow tables"
Synopsis: storing nonce salts alongside hashed passwords using a slow hashing algorithm considered a good thing to do.
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furlMon 10 September, 2007

2. A delusion that one has become or assumed the characteristics of a wolf or other animal.
add to del.icio.us. look up in del.icio.us.
add to furl
add to del.icio.us. look up in del.icio.us.
add to furl