helpermethod / bash-specs

A BDD testing framework for Bash inspired by Jasmine and roundup.
GNU General Public License v3.0
12 stars 4 forks source link

Output individual and accumulated execution time of specs #2

Closed helpermethod closed 10 years ago

helpermethod commented 12 years ago

Example:

up
  should change the current directory to the parent directory (0.001s)
  should change the current directory to the grandparent directory (0.001s)
  should fail if the current directory is the root directory (0.001s)
  should allow ~ as a valid basename (0.001s)

5 specs, 0 failed (0.053s)

See this SO question to get an idea on how to implement this.

helpermethod commented 12 years ago

Using date for measuring execution time has several flaws:

Thus, some combination of the time builtin and the TIMEFORMAT environment variable is preferrable.

helpermethod commented 11 years ago

Measuring and accumulating now works but somehow a return code of 0 (i.e. success) is always returned (it seems that somehow the actual return code gets swallowed).

helpermethod commented 11 years ago

The return code of the command substitution got obscured by the local builtin (which has a return code by itself). Declaring the variable first (using the local keyword) and then assigning a value to it afterwards solved the problem.

helpermethod commented 11 years ago

As the time command was executed in a subshell the error_message global variable could not be set. Writing the output of time to a file and not executing it in a subshell may solve the problem.