Redirect luatest stderr to stdout with new option#410
Draft
ochaplashkin wants to merge 2 commits intotarantool:masterfrom
Draft
Redirect luatest stderr to stdout with new option#410ochaplashkin wants to merge 2 commits intotarantool:masterfrom
stderr to stdout with new option#410ochaplashkin wants to merge 2 commits intotarantool:masterfrom
Conversation
16c2ad2 to
fe1d6dc
Compare
Contributor
|
What is the point of renaming the I would also highlight that mixing of the stdout and stderr streams reopens #392. tarantool/luatest#308 is too common, as for me. What is the test-run problem you want to solve with the change? Show stderr content from a luatest test when |
By default, test-run captures the stderr stream and redirects its to the
log file:
$ cat /tmp/t/001_foo-luatest/foo_test.log:
[001] Some error log
[001] My warning log
...
Use the new option `--show-capture` (abbr. `-c`) to redirect stderr to
stdout. Use it instead of the deprecated `--verbose` option.
The `--verbose` option will be ignored and output:
Argument ['--verbose'] is deprecated and is ignored.
Close tarantool/luatest#308
ca0b2dd to
de998a4
Compare
Author
What's new in the second commit?We have a two tests with logs: Passed test...
print('PRINT INTO test')
g.test_log = function()
print('PRINT INTO TEST INTERNAL')
log.error(' log')
log.warn('[WARNING] log')
log.info('[INFO] log')
log.verbose('[VERBOSE] log')
log.debug('[DEBUG] log')
g.server:exec(function()
require('log').error('[ERROR] server log')
require('log').warn('[WARNING] server log')
require('log').info('[INFO] server log')
require('log').verbose('[VERBOSE] server log')
require('log').debug('[DEBUG] server log')
end)
endFailed test...
print('PRINT INTO test')
g.test_log = function()
print('PRINT INTO TEST INTERNAL')
log.error(' log')
log.warn('[WARNING] log')
log.info('[INFO] log')
log.verbose('[VERBOSE] log')
log.debug('[DEBUG] log')
g.server:exec(function()
require('log').error('[ERROR] server log')
require('log').warn('[WARNING] server log')
require('log').info('[INFO] server log')
require('log').verbose('[VERBOSE] server log')
require('log').debug('[DEBUG] server log')
end)
t.assert(false) <-- Boom!
endSo, I tried to add the same logic that exists in What will we see when test passed?
$ ./test-run.py passed_test.lua
[001] engine-luatest/passed_test.lua [ pass ]
$ ./test-run.py -c passed_test.lua
log
[WARNING] log
[INFO] log
[001] engine-luatest/passed_test.lua [ pass ]
$ ./test-run.py -c -v passed_test.lua
log
[WARNING] log
[INFO] log
[001] engine-luatest/passed_test.lua
[001] Tarantool version is 3.0.0-alpha1-176-ga5d7f3429
[001] PRINT INTO test
[001] TAP version 13
[001] 1..1
[001] # Started on Mon Sep 25 14:52:56 2023
[001] # Starting group: engine-luatest.log
[001] PRINT INTO TEST INTERNAL
[001] ok 1 engine-luatest.passed.test_log
[001] # Ran 1 tests in 0.001 seconds, 1 succeeded, 0 failed
[001] [ pass ]What will we see when test failed?
$ ./test-run.py failed_test.lua
[001] engine-luatest/failed_test.lua [ fail ]
[001] Test failed! Output from reject file /tmp/t/rejects/engine-luatest/log2.reject:
[001] Tarantool version is 3.0.0-alpha1-176-ga5d7f3429
[001] TAP version 13
[001] 1..1
[001] # Started on Mon Sep 25 14:56:55 2023
[001] # Starting group: engine-luatest.log2
[001] not ok 1 engine-luatest.failed.test_log
[001] # ...workspace/vk/tarantool/test/engine-luatest/failed_test.lua:26: expected: a value evaluating to true, actual: false
[001] # stack traceback:
[001] # ...workspace/vk/tarantool/test/engine-luatest/failed_test.lua:26: in function 'engine-luatest.log2.test_log'
[001] # ...
[001] # [C]: in function 'xpcall'
[001] # artifacts:
[001] # server -> /tmp/t/001_engine-luatest/artifacts/server-lMMUEtMlRl5d
[001] # Ran 1 tests in 0.007 seconds, 0 succeeded, 1 failed
[001]
[001] [test-run server "luatest_server"] The log file /tmp/t/001_engine-luatest/failed_test.log has zero size
[Main process] Got failed test; gently terminate all workers...
[001] Worker "001_engine-luatest" got failed test; stopping the server...
$ ./test-run.py -c failed_test.lua
log
[WARNING] log
[INFO] log
[001] engine-luatest/failed_test.lua [ fail ]
[001] Test failed! Output from reject file /tmp/t/rejects/engine-luatest/failed.reject:
[001] Tarantool version is 3.0.0-alpha1-176-ga5d7f3429
[001] PRINT INTO test
[001] TAP version 13
[001] 1..1
[001] # Started on Mon Sep 25 14:58:09 2023
[001] # Starting group: engine-luatest.failed
[001] PRINT INTO TEST INTERNAL
[001] not ok 1 engine-luatest.failed.test_log
The result is the same as when running with the |
We synchronize the options of two tools: test-run and luatest. When luatest runs separate tarantool instance it duplicates the streams thereby we can see logs(warning, error, etc) and prints. We have added a context manager to create the same behavior with luatest. Close tarantool/luatest#308
de998a4 to
dfc7559
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
By default, test-run captures the stderr stream and redirects its to the log file:
Use the new option
--show-capture(abbr.-c) to redirect stderr to stdout. Use it instead of the deprecated--verboseoption.The
--verboseoption will be ignored and output:What's new in usage
🟢
-c, --show-capture- a new option. Show test logs in the stdout.🔴
--verbosehas been deprecated.Close tarantool/luatest#308