-
-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Report code coverage that includes P tests (#2478)
* Enable code coverage before P tests and stop it after Pester tests * this gets me to the point where I can run the whole coverage * Merge changes from Profiler so we can share the code easily * Measure cc * Fix inline * report to xml * Absolute path * Add sync script and sync * Exclude profiler script from scanning * Write xml * Coveragepublish@1 * remove cc debug message
- Loading branch information
Showing
12 changed files
with
490 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,58 @@ | ||
using System; | ||
// Copied from Profiler module, branch: Fix-error-autodetection, commit: 150bbcf Fix error autodetection | ||
|
||
using System; | ||
using System.Management.Automation; | ||
using System.Management.Automation.Language; | ||
using System.Reflection; | ||
|
||
namespace Pester.Tracing | ||
|
||
#if PESTER | ||
namespace Pester.Tracing; | ||
#else | ||
namespace Profiler; | ||
#endif | ||
|
||
class ExternalTracerAdapter : ITracer | ||
{ | ||
class ExternalTracerAdapter : ITracer | ||
{ | ||
private readonly object _tracer; | ||
private readonly MethodInfo _traceMethod; | ||
private readonly int _version = 0; | ||
private readonly object _tracer; | ||
private readonly MethodInfo _traceMethod; | ||
private readonly int _version = 0; | ||
|
||
public object Tracer => _tracer; | ||
public object Tracer => _tracer; | ||
|
||
public ExternalTracerAdapter(object tracer) | ||
{ | ||
// We got tracer that is not using the same types that we use here. Find a method based on the signature | ||
// and use that. This enables tracers to register even when they don't take dependency on our types e.g. Pester CC tracer. | ||
public ExternalTracerAdapter(object tracer) | ||
{ | ||
// We got tracer that is not using the same types that we use here. Find a method based on the signature | ||
// and use that. This enables tracers to register even when they don't take dependency on our types e.g. Pester CC tracer. | ||
|
||
_tracer = tracer ?? new NullReferenceException(nameof(tracer)); | ||
_version = 2; | ||
var traceMethod = tracer.GetType().GetMethod("Trace", new Type[] { | ||
_tracer = tracer ?? new NullReferenceException(nameof(tracer)); | ||
_version = 2; | ||
var traceMethod = tracer.GetType().GetMethod("Trace", new Type[] { | ||
typeof(string), // message | ||
typeof(IScriptExtent), // extent | ||
typeof(ScriptBlock), // scriptblock | ||
typeof(int) }); // level | ||
|
||
if (traceMethod == null) | ||
{ | ||
_version = 1; | ||
traceMethod = tracer.GetType().GetMethod("Trace", new Type[] { | ||
if (traceMethod == null) | ||
{ | ||
_version = 1; | ||
traceMethod = tracer.GetType().GetMethod("Trace", new Type[] { | ||
typeof(string), // message | ||
typeof(IScriptExtent), // extent | ||
typeof(ScriptBlock), // scriptblock | ||
typeof(int) }); // level | ||
} | ||
|
||
_traceMethod = traceMethod ?? | ||
throw new InvalidOperationException("The provided tracer does not have Trace method with this signature: Trace(string message, IScriptExtent extent, ScriptBlock scriptBlock, int level) or Trace(IScriptExtent extent, ScriptBlock scriptBlock, int level)"); | ||
} | ||
|
||
public void Trace(string message, IScriptExtent extent, ScriptBlock scriptBlock, int level) | ||
{ | ||
var parameters = _version == 2 | ||
? new object[] { message, extent, scriptBlock, level } | ||
: new object[] { extent, scriptBlock, level }; | ||
_traceMethod.Invoke(_tracer, parameters); | ||
} | ||
_traceMethod = traceMethod ?? | ||
throw new InvalidOperationException("The provided tracer does not have Trace method with this signature: Trace(string message, IScriptExtent extent, ScriptBlock scriptBlock, int level) or Trace(IScriptExtent extent, ScriptBlock scriptBlock, int level)"); | ||
} | ||
|
||
public void Trace(string message, IScriptExtent extent, ScriptBlock scriptBlock, int level, string functionName, string moduleName) | ||
{ | ||
var parameters = _version == 2 | ||
? new object[] { message, extent, scriptBlock, level } | ||
: new object[] { extent, scriptBlock, level }; | ||
_traceMethod.Invoke(_tracer, parameters); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
using System.Management.Automation; | ||
// Copied from Profiler module, branch: Fix-error-autodetection, commit: 150bbcf Fix error autodetection | ||
|
||
using System.Management.Automation; | ||
using System.Management.Automation.Language; | ||
|
||
namespace Pester.Tracing | ||
# if PESTER | ||
namespace Pester.Tracing; | ||
#else | ||
namespace Profiler; | ||
#endif | ||
|
||
public interface ITracer | ||
{ | ||
public interface ITracer | ||
{ | ||
void Trace(string message, IScriptExtent extent, ScriptBlock scriptBlock, int level); | ||
} | ||
void Trace(string message, IScriptExtent extent, ScriptBlock scriptBlock, int level, string functionName, string moduleName); | ||
} |
Oops, something went wrong.