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

[BUG] changes in test command execution #829

Open
Den-dp opened this issue Feb 12, 2024 · 4 comments
Open

[BUG] changes in test command execution #829

Den-dp opened this issue Feb 12, 2024 · 4 comments
Labels
bug Something isn't working needs-triage This issue has yet to be looked over by a core team member

Comments

@Den-dp
Copy link

Den-dp commented Feb 12, 2024

Current Behavior

after migration to 2.2.0 I see 2 issues:

  • running tests now leads to running a build
    2.1.2
    image
    2.2.0
    image

  • after the build I see that the test target is getting stuck and can't be stopped using Ctrl+C (might be powershell specific)
    image

Expected Behavior

  • nx test must run dotnet test but not dotnet build + dotnet test (not 100% sure this is right, but this is how it was early)
  • nx test must not stuck

Github Repo

No response

Steps to Reproduce

# generate empty workspace
npx create-nx-workspace@latest nxdotnet --preset=empty --workspaceType=integrated --ci=skip
cd nxdotnet
# install previous release of nx-dotnet
npx nx add @nx-dotnet/core@2.1.2
# generate library
npx nx g @nx-dotnet/core:library --name=foo-lib --language=C# --testTemplate=nunit --template=classlib --pathScheme=nx

2.1.2 test target behavior

> npx nx test foo-lib-test

> nx run foo-lib-test:test

Executing Command: dotnet "test" "C:\temp\nxdotnet\foo-lib-test\Nxdotnet.FooLib.Test.csproj" "--blame" "false" "--blame-crash" "false" "--blame-crash-collect-always" "false" "--blame-hang" "false"
  Determining projects to restore...
  Restored C:\temp\nxdotnet\foo-lib-test\Nxdotnet.FooLib.Test.csproj (in 147 ms).
  1 of 2 projects are up-to-date for restore.
  Nxdotnet.FooLib -> C:\temp\nxdotnet\dist\foo-lib\net7.0\Nxdotnet.FooLib.dll
  Checking module boundaries for foo-lib
  CONFIGURED undefined
  Nxdotnet.FooLib.Test -> C:\temp\nxdotnet\dist\foo-lib-test\net7.0\Nxdotnet.FooLib.Test.dll
  Checking module boundaries for foo-lib-test
  CONFIGURED undefined
Test run for C:\temp\nxdotnet\dist\foo-lib-test\net7.0\Nxdotnet.FooLib.Test.dll (.NETCoreApp,Version=v7.0)
Microsoft (R) Test Execution Command Line Tool Version 17.6.3 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Data collector 'Blame' message: All tests finished running, Sequence file will not be generated.
Data collector 'Blame' message: System.IO.FileNotFoundException: Collect dump was enabled but no dump file was generated.
   at Microsoft.TestPlatform.Extensions.BlameDataCollector.ProcessDumpUtility.GetDumpFiles(Boolean warnOnNoDumpFiles, Boolean processCrashed)
   at Microsoft.TestPlatform.Extensions.BlameDataCollector.BlameCollector.SessionEndedHandler(Object sender, SessionEndEventArgs args).

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 24 ms - Nxdotnet.FooLib.Test.dll (net7.0)

 ———————————————————————————

 >  NX   Successfully ran target test for project foo-lib-test (7s)
# migrate to 2.2.0
npx nx migrate @nx-dotnet/core@latest
npm i

2.2.0 test target behavior

> npx nx test foo-lib-test

   √    1/1 dependent project tasks succeeded [0 read from cache]

   Hint: you can run the command with --verbose to see the full dependent project outputs

 —————————————————————


> nx run foo-lib-test:build

Executing Command: dotnet "--version"
7.0.312
Executing Command: dotnet "build" "C:\temp\nxdotnet\foo-lib-test\Nxdotnet.FooLib.Test.csproj" "--configuration" "Debug" "--no-dependencies" "--verbosity" "minimal"
MSBuild version 17.6.10+2679cf5a9 for .NET
  Determining projects to restore...
  Restored C:\temp\nxdotnet\foo-lib-test\Nxdotnet.FooLib.Test.csproj (in 147 ms).
  1 of 2 projects are up-to-date for restore.
  Nxdotnet.FooLib.Test -> C:\temp\nxdotnet\dist\foo-lib-test\net7.0\Nxdotnet.FooLib.Test.dll
  Checking module boundaries for foo-lib-test
  CONFIGURED undefined

Build succeeded.
    0 Warning(s)
    0 Error(s)
Time Elapsed 00:00:02.09

> nx run foo-lib-test:test

HERE WE STUCK

Nx Report

> npx nx report

 >  NX   Report complete - copy this into the issue template

   Node   : 18.17.1
   OS     : win32-x64
   npm    : 9.9.2

   nx             : 18.0.4
   @nx/js         : 18.0.4
   @nx/workspace  : 18.0.4
   @nx/devkit     : 18.0.4
   @nrwl/tao      : 18.0.4
   typescript     : 5.3.3
   ---------------------------------------
   Community plugins:
   @nx-dotnet/core : 2.2.0

nx.json

{
  "$schema": "./node_modules/nx/schemas/nx-schema.json",
  "namedInputs": {
    "default": [
      "{projectRoot}/**/*",
      "sharedGlobals"
    ],
    "production": [
      "default"
    ],
    "sharedGlobals": []
  },
  "plugins": [
    "@nx-dotnet/core"
  ]
}

Failure Logs

No response

Additional Information

No response

@Den-dp Den-dp added bug Something isn't working needs-triage This issue has yet to be looked over by a core team member labels Feb 12, 2024
@AgentEnder
Copy link
Member

Hey @Den-dp - A build was always ran before your tests, but it was originally handled via the dotnet cli. We now pass --no-build to the dotnet test command, opting to build the project first manually. We do this s.t. the build can leverage the Nx cache, but also to avoid issues when running test in parallel.

I'll look into the command hanging, its possible thats something on the Nx side from the v17.3 / 18 changes.

@mrfelton
Copy link
Contributor

mrfelton commented Mar 1, 2024

Problem is though, that previously we could use noBuild option to prevent build happening prior to running the tests. But now there is no way to do that since the build is a task dependency and there is no way to skip task dependencies that I'm aware of.

This is a problem, because building is slow. Even with a cached build, it's slow to determine that no build needs to happen. We have a monorepo with 100+ projects and with the latest version running nx test on a single project can result in a huge amount of time running the build target across all of the dependencies, even if every single one has a cached build. It adds minutes onto a simple single project test run.

@AgentEnder
Copy link
Member

You can opt out of it by setting dependsOn: [] in the project.json test target, or in target defaults in nx.json.

It shouldn't be adding minutes, as determining cache hits should be fast (especially if daemon is active). If its taking minutes, I'd advise opening an issue on the main Nx repo as that's certainly not the goal.

@mrfelton
Copy link
Contributor

mrfelton commented Mar 1, 2024

I think the slowness issue is this nrwl/nx#19627. Setting NX_DAEMON=false gets the cache processing back to a reasonable speed (improves by a couple of orders of magnitude)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage This issue has yet to be looked over by a core team member
Projects
None yet
Development

No branches or pull requests

3 participants