Skip to content

CI: Running tests with xvfb for the clipboard to work #26932

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

Closed
wants to merge 8 commits into from
5 changes: 5 additions & 0 deletions ci/azure/posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,22 @@ jobs:
echo "Creating Environment"
ci/setup_env.sh
displayName: 'Setup environment and build pandas'

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
ci/run_tests.sh
displayName: 'Test'

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev && pushd /tmp && python -c "import pandas; pandas.show_versions();" && popd

- task: PublishTestResults@2
inputs:
testResultsFiles: 'test-data-*.xml'
testRunTitle: ${{ format('{0}-$(CONDA_PY)', parameters.name) }}

- powershell: |
$junitXml = "test-data-single.xml"
$(Get-Content $junitXml | Out-String) -match 'failures="(.*?)"'
Expand All @@ -90,6 +94,7 @@ jobs:
Write-Error "$($matches[1]) tests failed"
}
displayName: 'Check for test failures'

- script: |
export PATH=$HOME/miniconda3/bin:$PATH
source activate pandas-dev
Expand Down
5 changes: 5 additions & 0 deletions ci/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ do
fi

PYTEST_CMD="pytest -m \"$TYPE_PATTERN$PATTERN\" -n $NUM_JOBS -s --strict --durations=10 --junitxml=test-data-$TYPE.xml $TEST_ARGS $COVERAGE pandas"
if [[ "$(uname)" == "Linux" ]]; then
# This is required for the clipboard to work (X virtual frambuffer implements the X server API, required by the clipboard tools, without running an actual X server)
DISPLAY=:99.0
Copy link
Contributor

Choose a reason for hiding this comment

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

so u prob need to start xvfb much earlier and background it

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'm using xvfb-run, which starts it for the command, and stops it when the command finishes. It's what xvfb's got in the azure servers. I guess something else can be installed, but I'll see what I can do.

May be time to try again to call the tests just once (not twice for single and multi). :)

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 I’ve seen similar things for matplotlib headless tests. IIRC they add a 1-second sleep after this for the thing to start

PYTEST_CMD="xvfb-run $PYTEST_CMD"
fi
echo $PYTEST_CMD
# if no tests are found (the case of "single and slow"), pytest exits with code 5, and would make the script fail, if not for the below code
sh -c "$PYTEST_CMD; ret=\$?; [ \$ret = 5 ] && exit 0 || exit \$ret"
Expand Down