Fri, 03 Jul 2009

Simulating module load failure

I did a bit of hacking on JSON::Any today and added a new program to the test suite in the process. Since I have all the backend JSON handlers installed on my development machine (JSON, JSON::XS, JSON::DWIW, and the deprecated JSON::Syck), I needed a way to ensure some tests are skipped when one or more of those backends aren’t available.

A surprisingly simple solution came to mind:

touch lib/JSON/DWIW.pm

That created an empty file in the project which of course doesn’t return the requisite true value when require-ed. So, it simulated the need quite nicely.

The sheer joy this simple hack gave me probably marks me a geek more surely the mouseless Debian Linux, Xmonad-tiled-window-manager system I typed it on.

The only thing simpler was the fix required to make sure tests are skipped when a backend can’t be loaded:

-    diag "$backend: $@" and skip("backend failed to load", 8) if $@;
+    diag("$backend: $@"), skip("backend failed to load", 8) if $@;

Apparently, diag doesn’t return true. (Should it?)

Hmmm…following diag through its call chain, we find our way to Test::Builder::_print_comment, which explicitly calls return 0. I wonder why?

[/perl] [link]

Thu, 02 Jul 2009

Irony: using FOSS to suppress freedom

Just out of curiosity, I used Twitter search to see how Net::Twitter is being used.

I was dismayed to find warnings to ignore posts from Perl Net::Twitter with the #iranelection hashtag. Iranian government agents, they claim, are creating spambots with it.

CarlN: Govt agents here: Check signature of tweeters: posters from “Perl Net::Twitter” are most certainly government spambots. RT RT #iranelection 11:24 PM Jun 19th from web

jimmy_45: STOP supporting US backed coup in Iran. #IranElection #IranElection #tehran Tehran RT RT RT 3:28 PM Jun 20th from Perl Net::Twitter

iransource: 99% of tweets are from US backing a BLOODY revolution. People are dying. STOP destabilizing the Iranian state! #IranElection 5:25 PM Jun 20th from Perl Net::Twitter

When you donate your time and effort to produce free, open source software, you can’t control who uses it or how it’s used. The good guys and the bad guys have equal access.

Here’s hoping the good guys win!

[/perl] [link]

About this weblog

This site is the personal weblog of Marc Mims. You can contact Marc by sending e-mail to:
marc@questright.com.

Marc writes here about cycling, programming, Linux, and other items of personal interest.

This site is syndicated with RSS.

Archives

Credits

CSS stolen from Tom Coates who didn't even complain.