From bb75d555faab8e561114fde74fdece990bb17a1e Mon Sep 17 00:00:00 2001 From: virus Date: Mon, 29 Apr 2019 17:07:09 +0900 Subject: [PATCH] Add process to avoid overwrite files that specifed in options --- azure-pipelines.yml | 2 +- run-tests.xsh | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fefcb0e95..f0711fd92 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -36,7 +36,7 @@ jobs: - script: | call activate conda-test-$(python.version) pip install . - xonsh run-tests.xsh --timeout=10 --junitxml=junit/test-results.xml + xonsh run-tests.xsh --timeout=10 --junitxml=junit/test-results.%%d.xml displayName: 'Tests' # Publish build results diff --git a/run-tests.xsh b/run-tests.xsh index a869f0330..38292f6ec 100755 --- a/run-tests.xsh +++ b/run-tests.xsh @@ -1,10 +1,24 @@ #!/usr/bin/env xonsh +import sys +args = sys.argv[1:] + + +def replace_args(num): + """ + Replace %d to num for avoid overwrite files + + Example of args: --junitxml=junit/test-results.%d.xml + """ + return [ + (arg % num) if "%d" in arg else arg + for arg in args] + $RAISE_SUBPROC_ERROR = True run_separately = [ 'tests/test_ptk_highlight.py', ] -![pytest @($ARGS[1:]) --ignore @(run_separately)] -for fname in run_separately: - ![pytest @($ARGS[1:]) @(fname)] +![pytest @(replace_args(0)) --ignore @(run_separately)] +for index, fname in enumerate(run_separately): + ![pytest @(replace_args(index+1)) @(fname)]