-
Notifications
You must be signed in to change notification settings - Fork 18
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
Redirect luatest stderr
to stdout
with new option
#410
base: master
Are you sure you want to change the base?
Redirect luatest stderr
to stdout
with new option
#410
Conversation
16c2ad2
to
fe1d6dc
Compare
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
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)
end Failed 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!
end So, 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
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--verbose
option.The
--verbose
option will be ignored and output:What's new in usage
🟢
-c, --show-capture
- a new option. Show test logs in the stdout.🔴
--verbose
has been deprecated.Close tarantool/luatest#308