Monthly Archives: January 2008

Using the Delphi command line compiler on a Continuous Integration server

Recently, I got an email asking how to deploy the Delphi command line compiler for use on a continuous integration (CI) server. Since I’m no longer working at CodeGear nor coding in Delphi I forwarded the message to a few guys at CodeGear mentioning that it would be a good blog post but alas, I never got a response. Geeze, I didn’t think it had been that long guys! 🙂 Anyway…

I figured the question was worth a post if for no other reason than to start a conversation so other Delphi developers could contribute with their experience. Before we begin be sure to read your Delphi software license as I seem to recall there being some sort of issue related to the license regarding compiler deployment.

Getting the command line compiler to a build machine should be pretty straight forward though I’ve never had a need to do it myself since I was always working with the entire source tree including the compiler.

Basically, what’s needed is the Delphi compiler and the DCU/DCP’s from the products “lib” directory which means.

  • DCC32.EXE
  • The lib directory from your Delphi IDE source path

Aside from that here are some other suggestions for a build machine:

  • Using command line options (or a dcc32.cfg file) always specify an output path for the compiler, never place project related output in the same directory as DCU/DCP’s that are shipped with Delphi
  • Make sure you do a “clean” before each new build meaning run a process that deletes all of the compiler produced output from the previous build and verify that it actually works!

Be sure to read Language Reference Guide as I recall working with Nathan Tawill years ago on it and it was very good.

Lastly, another option would be to simply install a copy of the product on the build machine. Oh yeah, be sure to ask CodeGear to create an install that will take care of all this for you.

See also:
Other continuous integration posts
Video: Setting up a continuous integration environment

Ok, that’s my quick and dirty write up, your turn, what’s missing?

Configuring DNS CNAME and MX records for Google Apps on discountASP.NET

The other day I signed up for $g(Google Apps) for my domain allowing me to use $g(GMail) as my mail client among other things. Initially, I had a little trouble configuring the $g(MX records) in order to get GMail working on discountASP.NET (DASP) and I noticed on their support forums others had similar issues. I could send email from the account but couldn’t get replies because sending TO my address failed. The mistake I made was in the MX records where I prefixed my domain with “mail” which was incorrect, no prefix is required. Once I corrected the settings, based on forum reply from DASP, GMail worked instantly.

Here are my DNS settings for Google Apps:

CNAME Record Manager : [Help?]
Canonical Name Record: Creates an alias from one hostname to another.
Use of CNAME is generally not recommended.

Domain Name Destination TTL 3600 3600 3600 3600 3600

MX Record Manager : [Help?]
Mail Exchanger Record: Identifies the email server that handles email for a domain.


I really like discountASP.NET which is why I participate in their referral program. So far I’ve had 14 people use my referral ID so thanks to those of you who have signed up, I’ve already made my first $120! Btw, it’s nice to visit a forum for a company where you can consistently read messages that are thankful for such high quality support for a change.

Btw, be sure to check out Scott Hanselman’s post on Google Apps as it’s not the solution for everyone, at least not yet. I’m going to play with it for a bit and see how it works.

NDepend and static code analysis for .NET

Recently, I’ve been spending time analyzing code from a project I’m working on using NDepend 2.6. NDepend is described as…

…a static analyzer that simplifies managing complex .NET code bases.

It digs deep into your code providing an incredible level of detail. Should you decide to take a look at NDepend be sure to give yourself several hours to spelunk as there’s tons to dive into. For starters here is a screenshot of what you can expect when you load a project:

NDepend Static Code Analysis Tool

In this image the mouse (not pictured) is hovering over an assembly name in the Dependencies pane, in the center of this image. Simultaneously the assembly region is is highlighted in the Metrics pane, in the top right.

Querying your code

While I’m still very new to this tool and digging away the thing that’s really caught my attention is CQL. Here’s a closer look at the CQL Query pane:

NDepend CQL Queries Pane

CQL stands for Code Query Language and it’s exactly what it sounds like, SQL for code, the heart of NDepend. In fact, you can check out the CQL v1.5 spec. In the above image, the queries you see are provided by default when you load a new project. On the left is a list of query groups which is a one to many with the queries listed on the right. In the image at the top I’ve selected a query titled “Methods too big” which equates to this in CQL:

// <Name>Methods too big (NbLinesOfCode)</Name>
// METHODS WHERE NbLinesOfCode > 30 are extremely complex and
// should be split in smaller methods
// (except if they are automatically generated by a tool).
// See the definition of the NbLinesOfCode metric here

Notice the blue highlights on the Metrics pane, again the one with the gray sphere’s, which represent methods from the query result set. Double clicking any of the sphere’s opens that method in VS.NET, very nice. Btw, NDepend includes copy/paste syntax highlighting of CQL queries, also a nice touch.

NDepend CQL Intellisense

Clearly, CQL is incredibly powerful and the engine that drives the code analysis used in NDepend. I think it’s a very natural approach for .NET developers and if you’ve worked with SQL at all you’ll find picking up CQL straightforward. Although, NDepend does go one step further by providing CQL Intellisense making it easier to get started with the new query language.

While the Intellisense support is nice it would be even better if it listed things like assemblies, namespaces and types (among others) where appropriate rather than just listing “assembly” or “type”.

Continuous Integration Support

If you’ve followed my blog you know I’ve written quite a bit about CruiseControl.NET which NDepend integrates nicely with. Included is a command line tool which will generate your NDepend output for integration with your build results. Here is a short screencast available with more details so I’ll leave it at that.


I’ve already spent numerous hours exploring my code and playing with CQL and I still just scratching the surface. I’ve also managed to find and fix a number of issues and improve and optimize my code. The NDepend website has lots of screencasts on how to accomplish various tasks using NDepend and be sure to read Patrick’s blog for lots more information on NDepend.

What do you use for static code analysis?

In the interest of full disclosure, I was provided a copy of NDepend v2.6.3 for review with no strings attached for which I’d like to thank NDepend’s developer Patrick Smacchia for the license and providing such a great tool to the .NET community!

Is the new iPod Touch worth it?

I’ve gone back and forth on this for awhile now and I’m wondering what you think. I’ve read a bunch of $g(iPod Touch reviews) but nothing has really swayed me either way. Most of the reviews are pre-Mac World ’08 so details on the new features are scant. I did play with one while at the store and like the iPhone, it’s very slick and definitely has geek appeal. Another important question I have is whether or not the upcoming iPhone SDK will be supported? I asked two different people working at the Apple store over the weekend and didn’t get an straight yes or no answer, it was more of a “we don’t know”.

The main reason I haven’t/wouldn’t go with an iPhone is the price of the contract which would significantly increase my monthly bill, not something I’m interested in.

Anyway, what’s your opinion on the iPod Touch (post Mac World ’08 of course)?

CruiseControl.NET features beyond v1.3

The last official release of CruiseControl.NET was v1.3 from June 2007 but that doesn’t mean there hasn’t been ongoing work. I’ve been updating my CCNET sources recently and looking at some of the new features which include:

  • devenv task updated to VS.NET 2008
  • ExternalSourceControl source control provider
    <sourcecontrol type="external"> <executable>(path to command-line application)</executable> <args>(command-line parameters for application</args> <autoGetSource>(true/false like other sourcecontrol providers)</autoGetSource> <labelOnSuccess>(true/false like other sourcecontrol providers)</labelOnSuccess> <environment> <var>name=value</var> (environment variables to pass to the provider) <var>name=value</var> </environment> </sourcecontrol>
  • FilteredSourceControl block for specific comments / labels
  • Expand notification of modifying users to support more than one status (e.g., “Failed” + “Fixed” so you get both the bad news and the good news).
  • PlasticSCM source control support
  • Improved standard statistics report page
  • RSS feed for build status
  • RegEx support in the email publisher to allow for utilizing source control usernames as email addresses among other things
  • Lots of bug fixes in CCNET as well as CCTray

These are just some of the items I thought worth noting while perusing the SVN change log. There are lots of other changes, fixes etc. If you’re looking for CCNET improvements you might want to try and grab the source. I found building the tree to be quick and painless.

Facebook Starter Kits for VS.NET updated

Since I’ve had a lot of interest in the VS.NET Starter Kits I created for the Facebook development I thought it worth mentioning I’ve updated both to their latest releases.

Facebook Developer ToolKit is now at v1.5 (starter kit download)

Facebook.NET is now at v0.3 (starter kit download)

Here are the relevant blog posts:

Visual Studio Starter Kit for Facebook application development

VS.NET starter kit for Nikhil Kothari’s Facebook.NET


HTTP Load Testing with AutomatedQA's TestComplete 6 and Remote Agent

Recently, I was teaching a class where the client was interested in HTTP load testing for which Test Complete has great support. Test Complete ships with a tool called Remote Agent that can be installed separately and allows for HTTP load testing using virtual users on multiple machines all controlled by a single instance of TestComplete. In fact, you can load test with up to 250 virtual users allowing a single tester to easily leverage an entire network of computers.

The following outlines the steps I took to demonstrate how easy it is to setup and execute HTTP load tests.

Setting up an HTTP Load Test ProjectTestComplete Project Manager

The first step is to create a new HTTP Load Test project.

  1. Select File | New Project
  2. Click the HTTP Load Testing Template
  3. Click Ok
  4. The Project Wizard appears and you can simply click Finish which will give you a project that looks like the image to the right.

As you can see the project has several nodes by default.

  • Stations: represents the machines that will be conducting the tests. Master is my current machine, the one I’m running TestComplete on.
  • Tasks: is the HTTP traffic you’re interested in testing.
  • Tests: allows you to assign tasks to various stations for test execution.
  • Scripts: is for manually writing test automation.

Setting up Remote Agent

For this example, I’m using a virtual machine running Windows XP. I’ve installed TestComplete 6.0 and I’m running Remote Agent which runs in a console window on the desktop. If you’re going to try and duplicate my setup be sure that your VPC network adapter is not set for Shared networking (NAT).

image The next step is to setup the machines you’ll use for load testing under the Stations node of your project.

  1. Right click the Stations node and select Add New… (you should see the dialog to the right)
  2. Enter the IP address of your Remote Agent machine, in my case that’s
  3. Click Ok

This will give you a new node under Stations, “VPC” which is your VM, or the machine running Remote Agent.

Record an HTTP Task

The next step is to create the HTTP traffic you want to load test your server and the easiest way is using TestComplete’s recording facilities. For HTTP load testing this requires setting TestComplete to be a proxy for your web browser.

  1. Configure Internet explorer to use TestComplete as a proxy allowing it to monitor and record HTTP traffic. For IE you can do that from the Connections tab of the Internet Options dialog setting the proxy to localhost on port 9999. For Firefox open the Tools|Options dialog and look on the Advanced page, under the Network tab.
  2. Click the record button on the TestComplete toolbar and once recording begins click the “Record and HTTP Task” button (circled in red below):
  3. This will bring up the Select Load Testing dialog where you can decide to record a new HTTP traffic or append it to an existing task.
  4. Once you click OK you can begin recording HTTP traffic by simply using your browser. TestComplete will record the HTTP traffic and add it to the task you specified.

Once recorded you can modify the web requests to fit your needs. Here is an example of what the recorded HTTP traffic looks like:


Running HTTP Load Testing

The next step is to configure individual Stations to perform the Tasks you’ve created. To execute your tests, TestComplete sends the recorded HTTP traffic to the web server bypassing the browser which means clients hosting Remote Agent will have no UI appear on screen other than the agent itself.



As you can see I’ve configured one virtual user to sent HTTP traffic starting half a second after the Master with a User-Agent of IE6.

Running HTTP Load Testing

The final step is to run your HTTP load tests and examine the output. To do that you can simply right click your test under the Tests node in the Project Explorer. The results at first will appear overwhelming but undoubtedly provide you with a detailed report of how you server performed.


Wrap up

As you can see TestComplete makes it quick and easy to create and run HTTP Load Tests so if this is something you’re looking for you might want to give it a try.

[UPDATED: Jan, 17 2008] Fix a few typos, and clarify adding a new Stations node.

Exceptions in CruiseControl.NET revisited

The other day I wrote about configuring CruiseControl.NET to send email when an exception occurred at the project level, meaning outside of the actual “build” which technically equates to the <tasks> block. I’ve since spent some time trying to understand why the CCNet was changed to remove support for $g(PublishExceptions) and found revision 2567 to IntegrationRunner.cs where it was removed with a comment of “all exceptions during build break the build
deprecating PublishExceptions attribute”. That didn’t exactly provide the explanation I was looking for and AFAICT, this change has now left a gap in CruiseControl.NET where exceptions occurring outside of the <tasks> block can’t be published using a build publisher. So, unless you’re checking the log files regularly, or you’ve configured log4net using an SmtpAppender they’ll go unnoticed.

To figure this out I’ve been posting messages to the ccnet-devel group and thankfully I’m getting some response although it’s been a very slow conversation that’s had it’s share of missteps due, in part, to my incorrect phrasing of where exceptions were occurring. Originally, I was looking for guidance thinking I must be missing something. After a few more posts a change request and subsequent revision was made but the change addressed a situation I’m pretty sure can’t occur in the current code base short of a plug-in explicitly catching exceptions and setting the build status to “Exception” which isn’t what I was looking for.

I believe the necessary change to allow for integration exceptions to be published looks something like this (from IntegrationRunner.cs):

1 public IIntegrationResult Integrate(IntegrationRequest request)
2 {
3 IIntegrationResult result = resultManager.StartNewIntegration(request);
4 IIntegrationResult lastResult = resultManager.LastIntegrationResult;
5 try 6 {
7 CreateDirectoryIfItDoesntExist(result.WorkingDirectory);
8 CreateDirectoryIfItDoesntExist(result.ArtifactDirectory);
9 result.MarkStartTime();
10 result.Modifications = GetModifications(lastResult, result);
11 if (result.ShouldRunBuild())
12 {
13 Log.Info("Building: " + request);
14 Build(result);
15 PostBuild(result
16 Log.Info(string.Format("Integration complete: {0} - {1}",
17 result.Status, result.EndTime));
18 }
19 target.Activity = ProjectActivity.Sleeping;
20 return result;
21 }
22 catch (Exception ex)
23 {
24 result.Status = IntegrationStatus.Exception;
25 result.ExceptionResult = ex;
26 target.PublishResults(result);
27 return result;
28 }
29 }

I’ve added a try…catch to handle exceptions that occur during the integration process and call PostBuild() which calls FinishIntegration() and PublishResults(). That way any exception occurring during the integration process can be handled by any of the available publishers including the email publisher. Btw, the old PublishExceptions code looked similar. Of course, the code presented here isn’t the only, nor perhaps even the best way to handle this situation personally, I’m not fond of PostBuild() appearing twice but adding a finally block seemed to unnecessarily complicate the code. Since I don’t understand the reasoning behind removing the PublishExceptions tag it’s hard to know what the desired behavior here is but I’m pretty sure what’s checked in is probably not what was intended.

There is one other change I think is important as well which is to modify IntegrationResult.ShouldRunBuild() as follows (from IntegrationResult.cs):

1 public bool ShouldRunBuild()
2 {
3 return status == IntegrationStatus.Unknown &&
4 (BuildCondition.ForceBuild == BuildCondition || HasModifications());
5 } 

This change rather subtle but it allows for an ISourceControl plug-in to handle it’s own exceptions and still prevent the build from executing by setting IntegrationStatus to something other than “Unknown”. Without the check for IntegrationStatus.Unknown the build would run regardless of exceptions that occurred within the GetModifications() call. For example, here is a catch block you could use within your implementation of ISourceControl.GetModfications() to prevent the build from executing. However, this will only work if the above proposed changes are made to CCNet.

1 catch(Exception ex)
2 {
3 to.ExceptionResult = ex;
4 to.Status = ThoughtWorks.CruiseControl.Remote.IntegrationStatus.Exception;
5 return null;
6 }

In the event of an exception you’ll have the opportunity to have the exception published using your configured publishers. Additionally, the web dashboard will reflect the fact that the build is left in an Exception state.

Anyway, I’m going continue to work this issue and see if I can get either the above changes or some other solution integrated into CCNet though the thread on the groups seems to have died.

[UPDATE: Jan 4, 2008] Here is an SVN patch for these changes.
[UPDATE: Jan 9, 2008] Fix for IntegrationRunner.Integrate to simply publish the results in the event of an exception.