public void dialyzeWithExternalInclude() throws Exception {
// http://www.assembla.com/spaces/erlide/tickets/608-dialyzer---navigate-to-external-includes-from-markers
File externalFile = null;
IErlProject erlProject = null;
File externalIncludesFile = null;
final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
try {
// given
// an erlang project and an external file not in any project
final String projectName = "testproject";
erlProject = createTmpErlProject(projectName);
final String externalFileName = "external.hrl";
externalFile = createTmpFile(externalFileName,
"f([_ | _]=L) ->\n atom_to_list(L).\n");
externalIncludesFile = createTmpFile("external_includes",
externalFile.getAbsolutePath());
erlProject.getProperties().setExternalIncludesFile(
externalIncludesFile.getAbsolutePath());
DialyzerMarkerUtils.removeDialyzerMarkersFor(root);
// when
// putting dialyzer warning markers on the external file
final String message = "test message";
final int lineNumber = 2;
final IErlElementLocator model = ErlangEngine.getInstance().getModel();
DialyzerMarkerUtils.addDialyzerWarningMarker(model,
externalFile.getAbsolutePath(), lineNumber, message);
// then
// the marker should have the proper file name and the include file
// should appear in External Files
final IMarker[] markers = root.findMarkers(
DialyzerMarkerUtils.DIALYZE_WARNING_MARKER, true,
IResource.DEPTH_INFINITE);
assertThat(markers.length, is(greaterThan(0)));
for (final IMarker marker : markers) {
// for some reason, when running on Hudson, we get two identical