Skip to content

Validate with -testUsedAssemblies in a CI leg#60052

Merged
jcouv merged 8 commits intodotnet:mainfrom
jcouv:emit-diagnostics
Mar 16, 2022
Merged

Validate with -testUsedAssemblies in a CI leg#60052
jcouv merged 8 commits intodotnet:mainfrom
jcouv:emit-diagnostics

Conversation

@jcouv
Copy link
Member

@jcouv jcouv commented Mar 9, 2022

This identified a few issues tests that assert or throw when GetEmitDiagnostics() is called: VoidEvent, NullCoalescingOperatorWithTupleNames, ExternAliases4, CrossAssemblySupportingAndNotSupportingCovariantReturns, TestNullCoalesce_Dynamic

Verified the validation fails as expected with a canary.

Fixes #60086

@jcouv jcouv force-pushed the emit-diagnostics branch from 1830c32 to cd86d1a Compare March 10, 2022 00:34
@jcouv jcouv marked this pull request as ready for review March 10, 2022 04:24
@jcouv jcouv requested review from a team as code owners March 10, 2022 04:24
$env:ROSLYN_TEST_EMITDIAGNOSTICS = "true"
}

if ($testUsedAssemblies) {
Copy link
Member Author

@jcouv jcouv Mar 10, 2022

Choose a reason for hiding this comment

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

@AlekseyTs Should we enable testUsedAssemblies in a CI leg? Seems like it's unused at the moment. #Closed

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we enable testUsedAssemblies in a CI leg? Seems like it's unused at the moment.

I think it would be good to add a separate CI leg similar to the one used for IOperation testing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay. Let's keep that separate (there's a few questions, such as choosing a leg, how to deal with potential failures that might have snuck in).
Filed tracking issue.

Towards that goal, this PR fixes an issue with TestRunner that makes sure we copy environment variables to Helix machines where tests end up running.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should consider whether to group this set of "additional validation" flags into a single leg or to have separate legs. Recently we are trying to be sensitive about number of test legs introduced because:

  1. Each time we additionally run the tests increases the rate of spurious failures.
  2. Cost of provisioning the additional machines.

See #57313.

@jcouv
Copy link
Member Author

jcouv commented Mar 10, 2022

@cston @RikkiGibson @dotnet/roslyn-compiler for review. Thanks

Copy link
Member

@RikkiGibson RikkiGibson left a comment

Choose a reason for hiding this comment

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

Implementation looks good, but perhaps consideration from the team is required to decide whether to do this validation in the existing job or in a new job.


static void transferEnvironmentVariable(StringBuilder command, string setEnvironmentVariable, string variableName)
{
if (Environment.GetEnvironmentVariable(variableName) is string iop)
Copy link
Member

@RikkiGibson RikkiGibson Mar 10, 2022

Choose a reason for hiding this comment

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

Consider inlining. #Resolved

}
";
var compilation = CreateCompilation(source).VerifyDiagnostics();
// We use VerifyDiagnosticsOnly until this issue is fixed:
Copy link
Member

@RikkiGibson RikkiGibson Mar 10, 2022

Choose a reason for hiding this comment

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

Should we get emit diagnostics anyway and assert about the nature of the failure? I'm concerned that emit bugs may be inadvertently fixed without related test baselines getting updated, resulting in either introduction of redundant tests or reduced test coverage of the fix. Similar to the issue that comes up when 'Skip' is used in tests. #WontFix

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that skipped and conditional tests could drift, but conditional tests on NoUsedAssembliesValidation and NoIOperationValidation are how we deal with problematic tests in those CI legs at the moment. I'd rather not revisit that for purpose of this PR

$env:ROSLYN_TEST_EMITDIAGNOSTICS = "true"
}

if ($testUsedAssemblies) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should consider whether to group this set of "additional validation" flags into a single leg or to have separate legs. Recently we are trying to be sensitive about number of test legs introduced because:

  1. Each time we additionally run the tests increases the rate of spurious failures.
  2. Cost of provisioning the additional machines.

See #57313.

@jcouv jcouv marked this pull request as draft March 10, 2022 20:28
@jcouv jcouv changed the title Pull on emit diagnostics in tests in a CI leg Validate with -testUsedAssemblies in a CI leg Mar 10, 2022
@jcouv
Copy link
Member Author

jcouv commented Mar 10, 2022

FYI @jmarolf From discussion with Rikki and team, we're adding a new CI leg (debug, core, compiler tests only, with some additional validation added to every compiler test for used assemblies and emit diagnostics).

configuration: Debug
testArguments: -testCoreClr -testIOperation -testCompilerOnly

template: eng/pipelines/test-windows-job.yml
Copy link
Member

@jaredpar jaredpar Mar 10, 2022

Choose a reason for hiding this comment

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

template: eng/pipelines/test-windows-job.yml


Consider adding a comment here explaining why this job is diff than others. #Resolved


if ($testUsedAssemblies) {
Remove-Item env:\ROSLYN_TEST_USEDASSEMBLIES
}
Copy link
Member

Choose a reason for hiding this comment

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

Why was this removed?

@jcouv jcouv force-pushed the emit-diagnostics branch from d68b30d to 31074bc Compare March 10, 2022 21:29
@jcouv jcouv force-pushed the emit-diagnostics branch from 31074bc to 5406f87 Compare March 10, 2022 21:33
@jcouv
Copy link
Member Author

jcouv commented Mar 10, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s), but failed to run 1 pipeline(s).

@jcouv jcouv force-pushed the emit-diagnostics branch 2 times, most recently from 415a6d8 to 5c16f6d Compare March 11, 2022 06:46
@jcouv jcouv force-pushed the emit-diagnostics branch from 5c16f6d to 0b2e200 Compare March 11, 2022 08:34
@jcouv jcouv marked this pull request as ready for review March 11, 2022 17:14
}

[Fact]
[ConditionalFact(typeof(NoUsedAssembliesValidation))] // Tracked by https://github.com/dotnet/roslyn/issues/60045
Copy link
Member

@jaredpar jaredpar Mar 15, 2022

Choose a reason for hiding this comment

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

Why do you use comments here vs. putting the URL into the Reason property? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

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

Not much reason. Either one works

Copy link
Member

Choose a reason for hiding this comment

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

One appears in the test logs, one does not 🙂.

Co-authored-by: Jared Parsons <jaredpparsons@gmail.com>
- template: eng/pipelines/test-windows-job.yml
parameters:
testRunName: 'Test Windows CoreCLR TestUsedAssemblies Debug'
jobName: Test_Windows_CoreClr_TestUsedAssemblies_Debug
Copy link
Member

@RikkiGibson RikkiGibson Mar 15, 2022

Choose a reason for hiding this comment

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

nit: would change TestUsedAssemblies to UsedAssemblies here and in 'testRunName'. #Resolved

}

[Fact]
[ConditionalFact(typeof(NoUsedAssembliesValidation))] // Tracked by https://github.com/dotnet/roslyn/issues/60046
Copy link
Member

Choose a reason for hiding this comment

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

I see that 'VerifyDiagnosticsOnly' was removed and replaced with ConditionalFact. I would prefer if we didn't skip tests or make them conditional. Ideally, if the underlying bug were fixed here, this test would start failing, forcing us to update, which will end up preventing test duplication.

We could consider capturing the fact that an assertion fails in debug mode with the following pattern:

comp.VerifyDiagnosticsOnly(...);

#if DEBUG
Assert.Throws<InvalidOperationException(() => comp.VerifyEmitDiagnostics());
#endif

@jcouv jcouv enabled auto-merge (squash) March 16, 2022 01:08
@jcouv jcouv merged commit 839fe5e into dotnet:main Mar 16, 2022
@ghost ghost added this to the Next milestone Mar 16, 2022
@allisonchou allisonchou modified the milestones: Next, 17.2.P3 Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add -testUsedAssemblies checks to a CI leg

7 participants