Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User facing output to file diff #2749

Closed
wants to merge 3 commits into from

Conversation

michaelcfanning
Copy link
Member

@michaelcfanning michaelcfanning commented Dec 22, 2023

This change retrieves and persists user-facing output generated by functional tests. These strings are to be persisted alongside the generated .sarif files in the Expected directory in TestData. We are experimenting with this capability in one SARIF Driver framework use case. Once it's proven/refined, we should push that code deeper into the test API.


foreach (string key in keys)
{
string actualSarifText = actualSarifTextDictionary[key];
SarifLog actualSarifLog = JsonConvert.DeserializeObject<SarifLog>(actualSarifText);
if (actualSarifLog.Runs?[0].TryGetProperty("consoleOut", out string userFacingText) == true)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TryGetProperty

So here's the trick upstream users of this base class can do. If they'd like, they can populate the run with consoleOut to capture user-facing strings. We can (and should) build this deeper into the test infra but it will break everyone's tests (which will require baselining). So we're taking this spotfix for now.

@shaopeng-gh
Copy link
Collaborator

Will the generated .txt file same when running on different machines, does it contains the part that is the absolute path of the file that is having problem which will be different on the machine

@michaelcfanning
Copy link
Member Author

The non-deterministic repo root is normalized to a variable, e.g.:

$(SRC_ROOT)\src\Plugins\Tests\TestData\Example\Inputs\TST101_001.TestRule.ps1(4,43-69): warning STST101/001: '…111111' was flagged as a potential problem.


In reply to: 1867931239

Copy link
Collaborator

@shaopeng-gh shaopeng-gh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants