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

Add MSpec support #12

Open
mikeblakeuk opened this issue Mar 14, 2023 · 1 comment
Open

Add MSpec support #12

mikeblakeuk opened this issue Mar 14, 2023 · 1 comment

Comments

@mikeblakeuk
Copy link

Don't think this works with Machine Spec tests
machine/machine.specifications.runner.visualstudio#95

@mikeblakeuk
Copy link
Author

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 mikeblakeuk changed the title MSpec Add MSpec support Mar 21, 2023
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

No branches or pull requests

1 participant