mkorpela / pabot

Parallel executor for Robot Framework test cases.
https://pabot.org
Apache License 2.0
476 stars 152 forks source link

Allow for --processes auto to do the same as not setting it #588

Open Lakitna opened 5 months ago

Lakitna commented 5 months ago

Context

I maintain an Azure DevOps pipeline template that is used by multiple teams. In this template, I'm exposing a bunch of run options. Most relevant to this issue are "run tests in parallel" (using pabot) and "number of parallel processes" used.

The "number of parallel processes" used option takes a positive integer, auto, or all. I'm currently using the following code to achieve this (simplified and redacted):

parameters:
  - name: parallel
    type: boolean
    default: false
  - name: parallelProcesses
    default: "auto"
jobs:
  - job: "robot_framework"
    ...
    variables:
      - name: robotframeworkCli
        ${{ if and(eq(parameters['parallel'], true), eq(parameters['parallelProcesses'], 'auto')) }}:
          value: pabot --testlevelsplit --pabotlib
        ${{ elseif and(eq(parameters['parallel'], true), ne(parameters['parallelProcesses'], 'auto')) }}:
          value: pabot --testlevelsplit --pabotlib --processes ${{parameters.parallelProcesses}}
        ${{ else }}:
          value: robot
    steps:
      - powershell: |
          ${{ variables.robotframeworkCli }} my/amazing/test/path

The improvement

I would love to be able to call pabot with --processes auto. This should behave the same way as calling pabot without the --processes argument.

This small change can make my pipeline template a bunch simpler:

parameters:
  - name: parallel
    type: boolean
    default: false
  - name: parallelProcesses
    default: "auto"
jobs:
  - job: "robot_framework"
    ...
    variables:
      - name: robotframeworkCli
        ${{ if eq(parameters['parallel'], true) }}:
          value: pabot --testlevelsplit --pabotlib --processes ${{parameters.parallelProcesses}}
        ${{ else }}:
          value: robot
    steps:
      - powershell: |
          ${{ variables.robotframeworkCli }} my/amazing/test/path

If you're open to this change, please let me know and I'll open a PR ;)