Skip to content

Process: Support configuring log level keywords use #5204

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Log process config
... stdin:${SPACE*3}None
... alias:${SPACE*3}äliäs
... env:${SPACE*5}None
... log_level:${SPACE*2}None
Check Log Message ${tc[0, 1]} Process configuration:\n${config} level=DEBUG
${cwd} = Normalize Path ${DATADIR}/standard_libraries/process
${config} = Catenate SEPARATOR=\n
Expand All @@ -54,6 +55,7 @@ Log process config
... stdin:${SPACE*3}PIPE
... alias:${SPACE*3}None
... env:${SPACE*5}None
... log_level:${SPACE*2}None
Check Log Message ${tc[1, 1]} Process configuration:\n${config} level=DEBUG

*** Keywords ***
Expand Down
7 changes: 7 additions & 0 deletions atest/robot/standard_libraries/process/process_library.robot
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ Error in exit code and stderr output
Change current working directory
Check Test Case ${TESTNAME}


Running a process in a shell with log level
Check Test Case ${TESTNAME}

Input things to process
Check Test Case ${TESTNAME}

Run process in shell
Check Test Case ${TESTNAME}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/process/run_process_with_timeout.robot
Resource atest_resource.robot
Suite Setup Run Tests ${EMPTY} standard_libraries/process/run_process_with_timeout.robot
Resource atest_resource.robot

*** Test Cases ***
Finish before timeout
Expand Down
3 changes: 3 additions & 0 deletions atest/robot/standard_libraries/process/sending_signal.robot
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ Sending signal to a process with a handle

Sending signal to a process with a wrong handle
Check Test Case ${TESTNAME}

Sending signal to a process with a wrong handle with info log level
Check Test Case ${TESTNAME}
13 changes: 7 additions & 6 deletions atest/robot/standard_libraries/process/terminate_process.robot
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
*** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/process/terminate_process.robot
Resource atest_resource.robot
Suite Setup Run Tests ${EMPTY} standard_libraries/process/terminate_process.robot
Resource atest_resource.robot

*** Test Cases ***
Terminate process
${tc} = Check Test Case ${TESTNAME}
Check Log Message ${tc[1, 0]} Gracefully terminating process.
Check Log Message ${tc[1, 1]} Process completed.

Terminate process with debug log level
${tc} = Check Test Case ${TESTNAME}
Check Log Message ${tc[1, 0]} Gracefully terminating process.
Check Log Message ${tc[1, 1]} Process completed.

Kill process
${tc} = Check Test Case ${TESTNAME}
Check Log Message ${tc[1, 0]} Forcefully killing process.
Expand All @@ -23,10 +28,6 @@ Kill process running on shell
Also child processes are terminated
Check Test Case ${TESTNAME}

Also child processes are killed
[Tags] no-windows
Check Test Case ${TESTNAME}

Kill process when terminate fails
${tc} = Check Test Case ${TESTNAME}
Check Log Message ${tc[5, 0]} Gracefully terminating process.
Expand Down
19 changes: 17 additions & 2 deletions atest/robot/standard_libraries/process/wait_for_process.robot
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
*** Settings ***
Suite Setup Run Tests ${EMPTY} standard_libraries/process/wait_for_process.robot
Resource atest_resource.robot
Suite Setup Run Tests ${EMPTY} standard_libraries/process/wait_for_process.robot
Resource atest_resource.robot

*** Test Cases ***
Wait For Process
${tc} = Check Test Case ${TESTNAME}
Check Log Message ${tc[1, 0]} Waiting for process to complete.
Check Log Message ${tc[1, 1]} Process completed.

Wait For Process With Info Log Level
${tc} = Check Test Case ${TESTNAME}
Check Log Message ${tc[1, 0]} Waiting for process to complete.
Check Log Message ${tc[1, 1]} Process completed.

Wait For Process With Debug Log Level
${tc} = Check Test Case ${TESTNAME}
Check Log Message ${tc[1, 0]} Waiting for process to complete.
Check Log Message ${tc[1, 1]} Process completed.

Wait For Process With Error Log Level
${tc} = Check Test Case ${TESTNAME}
Check Log Message ${tc[1, 0]} Waiting for process to complete.
Check Log Message ${tc[1, 1]} Process completed.

Wait For Process Timeout
${tc} = Check Test Case ${TESTNAME}
Check Log Message ${tc[2, 0]} Waiting for process to complete.
Expand Down
24 changes: 24 additions & 0 deletions atest/testdata/standard_libraries/process/process_library.robot
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@ Run process in shell
Run Keyword And Expect Error * Run Process python -c "print('hello')" shell=False
Run Keyword And Expect Error * Run Process python -c "print('hello')" shell=false

Running a process in a shell with log level
${result}= Run Process python -c "print('hello')" shell=True log_level='info'
Result should equal ${result} stdout=hello
${result}= Run Process python -c "print('hello')" shell=joojoo log_level='DEBUG'
Result should equal ${result} stdout=hello
Run Keyword And Expect Error * Run Process python -c "print('hello')" shell=${False}
Run Keyword And Expect Error * Run Process python -c "print('hello')" shell=${0}
Run Keyword And Expect Error * Run Process python -c "print('hello')" shell=False
Run Keyword And Expect Error * Run Process python -c "print('hello')" shell=false

Input things to process
Start Process python -c "print('inp %s' % input())" shell=True stdin=PIPE
${process}= Get Process Object
Log ${process.stdin.write(b"42\n")}
Log ${process.stdin.flush()}
${result}= Wait For Process
Should Match ${result.stdout} *inp 42*

Assign process object to variable
${process} = Start Process python -c print('Hello, world!')
${result} = Run Process python -c import sys; print(sys.stdin.read().upper().strip()) stdin=${process.stdout}
Wait For Process ${process}
Should Be Equal As Strings ${result.stdout} HELLO, WORLD!

Get process id
${handle}= Some process
${pid}= Get Process Id ${handle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ On timeout process can be left running
${result} = Wait For Process handle=exceed
Should not be terminated ${result}

On timeout process can be left running with log_level
${result} = Run Process @{COMMAND} timeout=0.2 seconds
... on_timeout=CONTINUE alias=exceed log_level='Debug'
Should Be Equal ${result} ${None}
${result} = Wait For Process handle=exceed log_level='Info'
Should not be terminated ${result}

*** Keywords ***
Should not be terminated
[Arguments] ${result}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ Sending signal to a process with a wrong handle
[Documentation] FAIL Non-existing index or alias 'unknown'.
Send Signal To Process 2 handle=unknown

Sending signal to a process with a wrong handle with info log level
[Documentation] FAIL Non-existing index or alias 'unknown'.
Send Signal To Process 2 handle=unknown log_level='info'

*** Keywords ***
Killer signal
[Arguments] ${signal} ${shell}=False ${children}=0 ${group}=False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Terminate process
Should Be Empty ${result.stdout}
Should Be Empty ${result.stderr}

Terminate process with debug log level
${handle}= Some process
${result} = Terminate Process ${handle} log_level='debug'
Process Should Be Stopped ${handle}
Should Not Be Equal As Integers ${result.rc} 0
Should Be Empty ${result.stdout}
Should Be Empty ${result.stderr}

Kill process
${handle}= Some process
${result} = Terminate Process ${handle} kill=true
Expand Down
18 changes: 18 additions & 0 deletions atest/testdata/standard_libraries/process/wait_for_process.robot
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ Wait For Process
Process Should Be Stopped ${process}
Should Be Equal As Integers ${result.rc} 0

Wait For Process With Info Log Level
${process} = Start Python Process print('Robot Framework')
${result} = Wait For Process ${process} log_level='info'
Process Should Be Stopped ${process}
Should Be Equal As Integers ${result.rc} 0

Wait For Process With Debug Log Level
${process} = Start Python Process print('Robot Framework')
${result} = Wait For Process ${process} log_level='DEBUG'
Process Should Be Stopped ${process}
Should Be Equal As Integers ${result.rc} 0

Wait For Process With Error Log Level
${process} = Start Python Process print('Robot Framework')
${result} = Wait For Process ${process} log_level='Error'
Process Should Be Stopped ${process}
Should Be Equal As Integers ${result.rc} 0

Wait For Process Timeout
${process} = Start Python Process while True: pass
Process Should Be Running ${process}
Expand Down
Loading