changeset 18:d1c5ce19d0f7

added warning in case source info was not found in pdb
author Evgeniy.Koshkin
date Thu, 01 Aug 2013 18:34:06 +0400
parents af87768a0724
children c038e1a8c8a5
files agent/src/jetbrains/buildServer/symbols/PdbFilePatcher.java agent/src/jetbrains/buildServer/symbols/SymbolsIndexer.java tests/src/PdbFilePatcherTest.java
diffstat 3 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/agent/src/jetbrains/buildServer/symbols/PdbFilePatcher.java	Thu Aug 01 17:22:53 2013 +0400
+++ b/agent/src/jetbrains/buildServer/symbols/PdbFilePatcher.java	Thu Aug 01 18:34:06 2013 +0400
@@ -1,6 +1,8 @@
 package jetbrains.buildServer.symbols;
 
+import jetbrains.buildServer.agent.BuildProgressLogger;
 import jetbrains.buildServer.util.FileUtil;
+import org.apache.log4j.Logger;
 
 import java.io.File;
 import java.util.Collection;
@@ -10,6 +12,8 @@
  */
 public class PdbFilePatcher {
 
+  private static final Logger LOG = Logger.getLogger(PdbFilePatcher.class);
+
   private final PdbStrExe myPdbStrExe = new PdbStrExe();
   private final SrcToolExe mySrcToolExe = new SrcToolExe();
 
@@ -21,8 +25,14 @@
     myIndexInputProvider = indexInputProvider;
   }
 
-  public void patch(File symbolsFile) throws Exception {
+  public void patch(File symbolsFile, BuildProgressLogger buildLogger) throws Exception {
     final Collection<File> sourceFiles = mySrcToolExe.getReferencedSourceFiles(symbolsFile);
+    if(sourceFiles.isEmpty()){
+      final String message = "No source information found in pdb file " + symbolsFile.getAbsolutePath();
+      buildLogger.warning(message);
+      LOG.debug(message);
+      return;
+    }
     final File tmpFile = FileUtil.createTempFile(myHomeDir, "pdb-", ".patch", false);
     myIndexInputProvider.dumpStreamToFile(tmpFile, sourceFiles);
     myPdbStrExe.doCommand(PdbStrExeCommand.WRITE, symbolsFile, tmpFile, PdbStrExe.SRCSRV_STREAM_NAME);
--- a/agent/src/jetbrains/buildServer/symbols/SymbolsIndexer.java	Thu Aug 01 17:22:53 2013 +0400
+++ b/agent/src/jetbrains/buildServer/symbols/SymbolsIndexer.java	Thu Aug 01 18:34:06 2013 +0400
@@ -77,8 +77,9 @@
   public void afterCollectingFiles(@NotNull List<ArtifactsCollection> artifacts) {
     super.afterCollectingFiles(artifacts);
     if(myBuild == null || mySymbolsToProcess == null) return;
+    final BuildProgressLogger buildLogger = myBuild.getBuildLogger();
     if(myBuild.getBuildFeaturesOfType(SymbolsConstants.BUILD_FEATURE_TYPE).isEmpty()){
-      myBuild.getBuildLogger().warning(SymbolsConstants.BUILD_FEATURE_TYPE + " build feature disabled. No indexing performed.");
+      buildLogger.warning(SymbolsConstants.BUILD_FEATURE_TYPE + " build feature disabled. No indexing performed.");
       LOG.debug(SymbolsConstants.BUILD_FEATURE_TYPE + " build feature disabled. No indexing performed.");
       return;
     }
@@ -87,13 +88,13 @@
     final PdbFilePatcher pdbFilePatcher = new PdbFilePatcher(myBuild.getBuildTempDirectory(), new SrcSrvStreamProvider(myBuild.getBuildId(), myBuild.getCheckoutDirectory()));
     for(File pdbFile : pdbFiles){
       try {
-        myBuild.getBuildLogger().message("Indexing sources appeared in file " + pdbFile.getAbsolutePath());
-        pdbFilePatcher.patch(pdbFile);
+        buildLogger.message("Indexing sources appeared in file " + pdbFile.getAbsolutePath());
+        pdbFilePatcher.patch(pdbFile, buildLogger);
         mySymbolsToProcess.add(pdbFile);
       } catch (Throwable e) {
         LOG.error("Error occurred while patching symbols file " + pdbFile, e);
-        myBuild.getBuildLogger().error("Error occurred while patching symbols file " + pdbFile);
-        myBuild.getBuildLogger().exception(e);
+        buildLogger.error("Error occurred while patching symbols file " + pdbFile);
+        buildLogger.exception(e);
       }
     }
   }
--- a/tests/src/PdbFilePatcherTest.java	Thu Aug 01 17:22:53 2013 +0400
+++ b/tests/src/PdbFilePatcherTest.java	Thu Aug 01 18:34:06 2013 +0400
@@ -6,7 +6,6 @@
 import org.testng.annotations.Test;
 
 import java.io.File;
-import java.io.IOException;
 
 /**
  * @author Evgeniy.Koshkin
@@ -28,6 +27,6 @@
   public void testFoo() throws Exception {
     File tempFile = new File(myTestHomeDir, "tmp.pdb");
     FileUtil.copy(new File("c:\\temp\\JetBrains.CommandLine.Symbols.pdb"), tempFile);
-    myPatcher.patch(tempFile);
+    myPatcher.patch(tempFile, null);
   }
 }