-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update insert optional data tests and update indices visitor. (#1212)
* Update insert optional data tests and update indices visitor. * Delete speculatively needed file * Remove erroneous override of base visit method. * Rework summary comment on DeletesOutputsDirectoryOnClassInitializationFixture.
- Loading branch information
1 parent
9befb2e
commit 03a36f9
Showing
28 changed files
with
578 additions
and
256 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
42 changes: 42 additions & 0 deletions
42
src/Sarif.TestUtilities/DeletesOutputsDirectoryOnClassInitializationFixture.cs
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Microsoft. All rights reserved. Licensed under the MIT | ||
// license. See LICENSE file in the project root for full license information. | ||
|
||
using System.IO; | ||
|
||
namespace Microsoft.CodeAnalysis.Sarif.TestUtilities | ||
{ | ||
/// <summary> | ||
/// This class is an XUnit "class fixture." If a test class is marked with the interface | ||
/// IClassFixture<T>, then before XUnit runs any tests from the class, it will instantiate | ||
/// T (which must have a parameterless constructor). If T implements IDisposable, then after | ||
/// xUnit runs the last test method from the class, it will dispose the fixture. This mechanism | ||
/// allows class-level setup and teardown (although I don't know why they don't just reflect | ||
/// for static methods like ClassSetup and ClassTeardown). | ||
/// | ||
/// See https://xunit.github.io/docs/shared-context for more information about xUnit class fixtures. | ||
/// | ||
/// This particular fixture deletes any existing test output files that may have been produced | ||
/// by a previous run. It is designed for use on test classes that derive from FileDiffingTests. | ||
/// It is required because FileDiffingTests emits the outputs from each test to a common directory, | ||
/// to allow diffing an entire directory of failing tests. If each test case deleted this directory, | ||
/// then at the end it would contain only the output from the last failing test. | ||
/// | ||
/// Each class that derives from FileDiffingTests can declare its own derived fixture class if | ||
/// it wants to override the virtual TypeUnderTest or OutputFolderPath properties, but there seems | ||
/// no good reason to do this. | ||
/// </summary> | ||
public abstract class DeletesOutputsDirectoryOnClassInitializationFixture | ||
{ | ||
protected virtual string TypeUnderTest => this.GetType().Name.Substring(0, this.GetType().Name.Length - "TestsFixture".Length); | ||
|
||
protected virtual string OutputFolderPath => Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location), "UnitTestOutput." + TypeUnderTest); | ||
|
||
public DeletesOutputsDirectoryOnClassInitializationFixture() | ||
{ | ||
if (Directory.Exists(OutputFolderPath)) | ||
{ | ||
Directory.Delete(OutputFolderPath, recursive: true); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.