shellspec: Shellspec can not collect data with the profile option enabled
Hello, I try to use the profile option, but the formatter get no proper data.
# shellspec --profile spec/em_spec.sh
Running: /bin/bash [bash 5.1.4(1)-release]
............/lib/shellspec/lib/general.sh: line 538: * 10: syntax error: operand expected (error token is "* 10")
Aborted with status code [executor: 0] [reporter: 0] [error handler: 102]
Fatal error occurred, terminated with exit status 102.
This is a problem in shellspec_shift10() because “$2” is empty. Therefore, I try find the way the function will be called.
But this ended because I can not find the code where “$time_real” filled with proper values. See /lib/shellspec/lib/libexec/reporter/profiler_formatter.sh in profiler_end() in the line
read_profiler callback "$profiler_tick_total" "$time_real" \
< "$SHELLSPEC_PROFILER_LOG" \
> "$SHELLSPEC_PROFILER_REPORT"
The time_real is empty, is ‘’. If I assign “0” to the empty “$time_real” I get no useful report but Shellspec finished without an error.
My question, where the variable “$time_real” came from?
Sorry, I can not find, what is going wrong, Lutz
p.s. I use shellspec 0.28.1 dist version.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 34 (19 by maintainers)
Commits related to this issue
- fix: Added support for comma (`,`) as decimal separator in some locales - Fixes #274 The `--profiler` option now works as expected on locales which had the decimal separator set as comma (`,`) and no... — committed to LukeSavefrogs/shellspec by LukeSavefrogs 4 years ago
- Merge pull request #281 from LukeSavefrogs/master fix: Added support for comma (`,`) as decimal separator - Fix #274 — committed to shellspec/shellspec by ko1nksm 3 years ago
- Rewrite the code to execute the executor This is the following workaround https://github.com/shellspec/shellspec/issues/274#issuecomment-2139845019 But the bug where user time and sys time were not ... — committed to shellspec/shellspec by ko1nksm 2 years ago
- Improve stability on ksh93t Workaround for file descriptor malfunction when specifying locale See below https://github.com/shellspec/shellspec/issues/274 — committed to shellspec/shellspec by ko1nksm 2 years ago
- fix: Added support for comma (`,`) as decimal separator in some locales - Fixes #274 The `--profiler` option now works as expected on locales which had the decimal separator set as comma (`,`) and no... — committed to PeterJRiches/shellspec by LukeSavefrogs 4 years ago
- Rewrite the code to execute the executor This is the following workaround https://github.com/shellspec/shellspec/issues/274#issuecomment-2139845019 But the bug where user time and sys time were not ... — committed to PeterJRiches/shellspec by ko1nksm 2 years ago
- Improve stability on ksh93t Workaround for file descriptor malfunction when specifying locale See below https://github.com/shellspec/shellspec/issues/274 — committed to PeterJRiches/shellspec by ko1nksm 2 years ago
Hello Koichi Nakashima, nice to see IBM make AIX available via a cloud service for developers. I was not aware of this option to get access to a IBM AIX system.
You are right, the KSH88 is very old and I do not know the reason IBM still use KSH88 as a default shell. I will start testing in a real AIX system next week, based on the github master.
Last week I make MKSH ([mksh @(#)MIRBSD KSH R59 2020/10/31]) available on AIX and shellspec works well, I can not find errors based on the shellspec tests, the tests are passed only 47 are skipped.
AIX 7.2
shellspec -s /home/j123450/bin/mksh spec
Running: /home/j123450/bin/mksh [mksh @(#)MIRBSD KSH R59 2020/10/31] Finished in 96.09 seconds (user 27.02 seconds, sys 3.18 seconds) 1619 examples, 0 failures, 47 skips (muted 33 skips)
Linux SLES 12/15 and RHEL 9 (I think)
shellspec -s /bin/mksh spec
Running: /bin/mksh [mksh @(#)MIRBSD KSH R50 2015/04/19 SLES] Finished in 43.89 seconds (user 38.07 seconds, sys 11.15 seconds) 1619 examples, 0 failures, 45 skips (muted 33 skips)
MacOS
shellspec -s /bin/mksh spec
Running: /bin/mksh [mksh @(#)MIRBSD KSH R59 2020/10/31] Finished in 69.46 seconds (user 51.00 seconds, sys 23.35 seconds) 1619 examples, 0 failures, 45 skips (muted 33 skips)
I compare the skipped tests to see the differences, for the MKSH. And I compare the KSH93 based tests on AIX and Linux.
Thanks for all your help/support. I’ll be back next week, Lutz
However, it is not clear whether this fix has completely fixed the issue.
Fixes were added to master.
The time should be measured correctly and the profiler should work correctly.
Bonus: The reimplemented locale-independent
shellspec-time.shcan be run alone.Hello, based on the shellepc master (45b02e0) and “LANG=C” the tests are passed successfully with the KSH93 also.
The tests with the KSH93 looks similar to the BASH (version 5.2!) tests now.
Based on “LANG=C” no NLSPATH is found in my AIX environment, therefore no messages are translated and the expected message text is found. The runtime time values are available also.
Have a nice weekend, Lutz
p.s. Nice to see, how easy a (inappropriate) LANG setting confuse lots of scripts. On the other hand, I know this problem, some of the used Java environments/application switch to “LANG=de_DE” or “LANG=de_DE.UTF-8”, therefore some messages are in german and somtimes partial messages are in german only. However, I was not aware that “LANG=en_US” does not necessarily use the default message text.
Hello, nice to see a german language pack create german messages, the NLS packages are not installated in our environments, the “en_US” language is installed only, by default.
In general I use “en_US” or “en_US.UTF-8”. This fit well (I thought) in the past, but I try do some tests based on “C”, tomorrow.
From my point of view the “/bin/time -p” problem can not fixed, as long as the NLS messages are used, the messages can not handled properly. The fix from LukeSavefrogs fix the “.”/“,” problem, but if a NLS package is available, the messages are not properly handled, because values are not properly assigned.
But “C” is a good idea.
Lutz
Hello, thanks for your answer. The used AIX environment is similar.
Based on your sample to gather some more information, my output looks similar, but the test failed.
The KSH93 version number is the same, but the files size is not the same.
The only ugly environment variables are set/used:
And “/opt/freeware/bin” is in the path, to make some Linux/GNU tools available in the AIX environment.
The used LANG and NLSPATH variables are the reason for the problem with the “time -p” command output, but this is an other storry. But you can check your NLSPATH to find the translated messages, in your AIX environment.
If I check the NLSPATH, I find messages for en_US only.
A funny test result, if I do this (based on your last sample).
Every think works well. And “LANG=EN_US” work well too, but “LANG=en_US” does not. With the suggest LANG “DE_DE” or “de_DE” the “time -p” looks like expected, too.
It is a AIX LANG environment setting/handling problem? Lutz
Very nice indeed 😳
Hello (back to MKSH), tests with MKSH on AIX (compared to Linux and MacOS) also skips the following tests, because “/dev/stdin” does not exist.
The BASH will simulate it (on AIX), I think.
But MKSH and KSH test the dev filesystem.
But the file does not exist.
Nice to see, Lutz
Thank you for taking the time to look into this issue.
It’s good to see you back in action 😄
@lutzmad
I have registered with IBM cloud and modified it to work with ksh93t+ on AIX 7.2 and ksh93u+ on AIX 7.3. The fixes are included in the latest master. Please note that the problems that did not work with ksh93 are not related to locale issues. This is a bug related to the virtual subshell of ksh93.
There are no plans to support sh (Version M-11/16/88f). This ksh88 is very old (released around 1995?), and although AIX seems to claim that it is POSIX compliant, it probably has bugs in its errexit-related behaviour. It is quite hard to support this.
Thanks for the report. It is very interesting.
When I wrote these codes, I apparently did not know about the time command. ShellSpec will use
time -pin preference to the external command time if it is present.https://github.com/shellspec/shellspec/blob/166e4f0523c958033b6baea5c1151c432419f5e6/shellspec#L414-L423
In ksh, the
timecommand is an internal command, but in some cases an external command is invoked. (sigh)The report shows that
/usr/bin/timeon AIX uses locale-dependent decimal point symbol. The same applies to bash. My understanding is thatNLSPATHis the path to the message catalog and I assume it has nothing to do with the decimal point symbol. This issue will be fixed in merge #281. It will be merged soon.However, there is another issue. Implementations of the various
timecommands can change their format via environment variables. The current implementation does not work well when a non-default format is specified. Eventually I am considering addressing this issue.Hello, no problem.
I will add additional “time” command output to the issue and I try to find out which “time” command is used. Lutz
@LukeSavefrogs Thanks for your help. And I’m sorry for neglecting you guys for so long.
Perhaps #281 can be merged without problems. ShellSpec must work in all locales. I did not pay enough attention to the locale when I wrote that code. Shells and commands have historically respected locales. However, not all.
The
timecommand is built into the shell in some shells and not in others. In ksh, thetimecommand invokes the built-in shell when no options are specified, but invokes an external command when options are specified. That is very confusing.bash is usually invoked by the shell built-in
timecommand. Its behavior differs from that of the external (GNU)timecommand.Hello Luca, I try to add your suggested modification tomorrow. I used my MacOS, but Shellspec collect profile data as expected in the MacOS environment. Lutz
p.s. I use the Bash shell in the Linux (and AIX) environment. The LANG is not C, we use de_DE with/without UTF-8 in general.
In a MacOS environment, the time output does not depend to the used LANG.
In the AIX ksh environment (my default shell, but I like the ksh, sorry), the time output honour the used LANG. This is the time command used by Shellspec, I think.
And in the Linux and AIX bash environment, also.