ParallelTestingSample-dotnet-core icon indicating copy to clipboard operation
ParallelTestingSample-dotnet-core copied to clipboard

Add MSpec support

Open mikeblakeuk opened this issue 2 years ago • 1 comments

Don't think this works with Machine Spec tests https://github.com/machine/machine.specifications.runner.visualstudio/pull/95

mikeblakeuk avatar Mar 14 '23 15:03 mikeblakeuk

This is what I have so far


  - bash: |
      ulimit -a
      ulimit -s 65534 #not working to try and fix  "##[error]Argument list too long"
      totalAgents=$SYSTEM_TOTALJOBSINPHASE
      agentNumber=$SYSTEM_JOBPOSITIONINPHASE

      echo "Searching ${{ parameters.dll }} for ${{ parameters.testFilters }}"
      echo "Filter not used for dotnet list so some tests will be skipped in the batch"
      dotnet test ${{ parameters.dll }} --list-tests > rawTestList.txt

      tail -n +5 "rawTestList.txt" > testList.txt #skip headers

      totalTests=$(grep -c ".*" testList.txt)

      filterProperty="TestCase.DisplayName" #MSpec
      if [ $totalAgents -eq 0 ]; then totalAgents=1; fi
      if [ -z "$agentNumber" ]; then agentNumber=1; fi

      batchSize=$((totalTests/totalAgents))

      endAt=$(($agentNumber * $batchSize))
      startAt=$((($endAt - $batchSize) + 1))
      if [ $agentNumber -eq $totalAgents ]; then endAt=100000; fi

      echo "Total agents: $totalAgents"
      echo "Agent number: $agentNumber"
      echo "Total Tests: $totalTests"
      echo "Batch Size $batchSize"
      echo "Tests $startAt to $endAt (inc)"

      echo "Target tests:"

      shopt -s extglob #to trim whitespace

      i=$((0))
      while IFS="" read -r p || [ -n "$p" ]
      do
       i=$(($i + 1))
       if [ $i -ge $startAt ] && [ $i -le $endAt ]
       then
         targetTestName=${p##+([[:space:]])}
         echo "$i:$targetTestName"
         filter+="|${filterProperty}=${targetTestName}"
       fi
      done < testList.txt

      filter=${filter#"|"}

      echo "##vso[task.setvariable variable=targetTestsFilter]$filter"
      echo "Slicing filter condition: $filter"

mikeblakeuk avatar Mar 21 '23 09:03 mikeblakeuk