SiKing

August 24, 2009

pwned by Windows

Filed under: automation,windows — SiKing @ 3:50 pm
Tags:

I am starting to put together a new piece of a continuous integration framework (the self-test part, of course). This one has to be done on a Windows platform, specifically it has to run on XP and Vista, a first for me.

I am used to having everything that I could possibly need at my fingertips on a base install of Linux. I can’t remember EVER having to go and hunt for some tool that I would need to get something like this done that was not already installed.

I first decided to see how far I could go with a base Windows install; that is, the minimum amount of tools that are not part of the original install. This means that I tried to resort to pure .bat scripting. 😥

Syncing different Windows machines

As is often the case, this has to run on multiple machines. I am just too lazy (and error prone) to go and make one small change on every single machine every time I update something. I want the framework to be self-updating! In order to achieve that, I had to install SVN on all he machines. My first rule broken, and I did not even get started. I did not even try to work around this one: some sick munched up network test if a drive is mounted properly, copy over network if the machine is not down, verify the copied files, decide which one is considered the master, …

Getting the day of week on Windows

I want different tests to run on different days of the week – this is strictly a management decision, there was no technical reason to do this. No big deal. In pure .bat scripting this is quite difficult to get, but not impossible … or is it?

The only command that I could find that gives you the day of week is date /T. It dumps out something in the format: “day date”, where “day” is a three-letter code for the day of week, like “Mon”, “Tue”, etc; and “date” is the current date. Now how to parse that? After like an hour of Googling and browsing the specs, I ended up with:

for /F "tokens=1" %%d in ("%date%") do set day=%%d

Nice, huh? They even have a different way of naming the variables inside the loop, depending if you are doing it from the command line or from a script! 😯 To tell you the honest truth, I am not really certain how this actually works. However, the first time I ran it on one of my test machines, %day% ended up being something like “18/08/09”. I’m thinking WTF? Tried it on another machine and got “Tue”. After some more trial and error, I discovered that the output of the date command varies depending on what locale you have set in your preferences. What sick sadistic MF over at Redmond thought this would be a good idea?

Scheduling things in Windows

Of course not everything everywhere is the same. Some parts of the tests need to change between different machines. From the Linux world, I normally did this through environment variables. Bill’s posse decided to outdo Linux by introducing three types of environment variables, only two of which are properly documented! After some trial and error I found a combination that worked … until I tried to run my tests as a Scheduled task. The facts that the tools for scheduling a task 1) are found in completely different location between XP and Vista, 2) have completely redesigned interface, and not for better, and 3) have their file formats that you export/import totally incompatible between the two, no longer dissuaded me. It makes work that much more interesting. But the fact that different variables are passed to the scheduled tasks in different versions of the OS, is another example of Windows’ big middle finger for the programming world.

There was a time once that I used to run a liberated version of Windows on my machine. Today, they could not pay me enough to install that piece of dung on my machine. I wouldn’t want it even for free!

Next: PowerShell. 🙄

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: