update prezto
This commit is contained in:
@@ -1,3 +1,21 @@
|
||||
## v0.6.6
|
||||
|
||||
- The `rbenv` segment is no longer a default segment in the LPROMPT.
|
||||
- PR #959 - Fixing issue in v0.6.5 where we changed some color codes.
|
||||
- PR #934 - Add Tests
|
||||
- PR #884 - test-in-docker: fix with newer ZSH versions
|
||||
- PR #928 - [Docs] Add etc state description in dir docs
|
||||
- PR #937 - Use SUDO_COMMAND to check for sudo
|
||||
- PR #925 - [Bugfix] Resolve #918 Transparent background
|
||||
- PR #923 - Fix font issue debugging script
|
||||
- PR #921 - Add missing colors to fix color comparison
|
||||
- PR #951 - Add fallback icon for missing linux distro icons
|
||||
- PR #956 - Fix broken link in readme
|
||||
- Fixed #936 - fallback icons for Linux distros
|
||||
- Fixed #926 - `etc` state for `dir` segment in docs
|
||||
- Fixed #852 - `sudo` detection got crazy, there. sorry, everyone.
|
||||
- Fixed #927 - more default color issues.
|
||||
|
||||
## v0.6.5
|
||||
|
||||
- Multiple PRs: General fixes to README, improved documentation.
|
||||
|
@@ -70,7 +70,7 @@ variables to your `~/.zshrc`.
|
||||
|
||||
| Variable | Default Value | Description |
|
||||
|----------|---------------|-------------|
|
||||
|`POWERLEVEL9K_LEFT_PROMPT_ELEMENTS`|`(context dir rbenv vcs)`|Segment list for left prompt|
|
||||
|`POWERLEVEL9K_LEFT_PROMPT_ELEMENTS`|`(context dir vcs)`|Segment list for left prompt|
|
||||
|`POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS`|`(status root_indicator background_jobs history time)`|Segment list for right prompt|
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ The table above shows the default values, so if you wanted to set these
|
||||
variables manually, you would put the following in
|
||||
your `~/.zshrc`:
|
||||
```zsh
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs)
|
||||
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir vcs)
|
||||
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
|
||||
```
|
||||
#### Available Prompt Segments
|
||||
@@ -357,13 +357,24 @@ end of the hostname.
|
||||
|`POWERLEVEL9K_ALWAYS_SHOW_USER`|false|Always show the username, but conditionalize the hostname.|
|
||||
|`POWERLEVEL9K_CONTEXT_TEMPLATE`|%n@%m|Default context prompt (username@machine). Refer to the [ZSH Documentation](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html) for all possible expansions, including deeper host depths.|
|
||||
|
||||
This segment can have different states. They might help you to visualize your
|
||||
different privileges. Read more about styling with states [here](https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt#special-segment-colors).
|
||||
|
||||
| State | Meaning |
|
||||
|---------------|----------------------------------------------------------|
|
||||
| `DEFAULT` | You are a normal user |
|
||||
| `ROOT` | You are the root user |
|
||||
| `SUDO` | You are using elevated rights |
|
||||
| `REMOTE_SUDO` | You are SSH'ed into the machine and have elevated rights |
|
||||
| `REMOTE` | You are SSH'ed into the machine |
|
||||
|
||||
##### date
|
||||
|
||||
The `date` segment shows the current system date.
|
||||
|
||||
| Variable | Default Value | Description |
|
||||
|----------|---------------|-------------|
|
||||
|`POWERLEVEL9K_DATE_FORMAT`|`%D{%d.%m.%y}`|[ZSH time format](http://zsh.sourceforge.net/Doc/Release Prompt-Expansion.html) to use in this segment.|
|
||||
|`POWERLEVEL9K_DATE_FORMAT`|`%D{%d.%m.%y}`|[ZSH time format](http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Date-and-time) to use in this segment.|
|
||||
|
||||
##### dir
|
||||
|
||||
@@ -375,12 +386,14 @@ Powerline" fonts, there are additional glyphs, as well:
|
||||
| None | None |  | At the root of your home folder |
|
||||
| None | None |  | Within a subfolder of your home directory |
|
||||
| None | None |  | Outside of your home folder |
|
||||
| None | None | ⚙ | Within the `/etc` directory |
|
||||
|
||||
To turn off these icons you could set these variables to an empty string.
|
||||
```zsh
|
||||
POWERLEVEL9K_HOME_ICON=''
|
||||
POWERLEVEL9K_HOME_SUB_ICON=''
|
||||
POWERLEVEL9K_FOLDER_ICON=''
|
||||
POWERLEVEL9K_ETC_ICON=''
|
||||
```
|
||||
You can limit the output to a certain length by truncating long paths.
|
||||
Customizations available are:
|
||||
@@ -561,6 +574,19 @@ Variable | Default Value | Description |
|
||||
|----------|---------------|-------------|
|
||||
|`POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW`|`false`|Set to true if you wish to show the rbenv segment even if the current Ruby version is the same as the global Ruby version|
|
||||
|
||||
##### pyenv
|
||||
|
||||
This segment shows the version of Python being used when using `pyenv` to change your current Python stack.
|
||||
|
||||
The `PYENV_VERSION` environment variable will be used if specified. Otherwise it figures out the version being used by taking the output of the `pyenv version-name` command.
|
||||
|
||||
* If `pyenv` is not in $PATH, nothing will be shown.
|
||||
* If the current Python version is the same as the global Python version, nothing will be shown.
|
||||
|
||||
| Variable | Default Value | Description |
|
||||
|----------|---------------|-------------|
|
||||
|`POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW`|`false`|Set to true if you wish to show the pyenv segment even if the current Python version is the same as the global Python version|
|
||||
|
||||
##### rspec_stats
|
||||
|
||||
See [Unit Test Ratios](#unit-test-ratios), below.
|
||||
|
@@ -1,25 +1,45 @@
|
||||
# Structure
|
||||
# Tests
|
||||
|
||||
The Unit-Tests do not follow exactly the file structure of Powerlevel9k itself.
|
||||
## Automated Tests
|
||||
|
||||
## Basic Tests
|
||||
The Unit-Tests do not follow exactly the file structure of Powerlevel9k itself,
|
||||
but we try to reflect the structure as much as possible. All tests are located
|
||||
under `test/`. Segment specific tests under `test/segments/` (one file per
|
||||
segment).
|
||||
|
||||
Basic Tests belong in `test/powerlevel9k.spec` if they test basic functionality of
|
||||
Powerlevel9k itself. Basic functions from the `functions` directory have their
|
||||
Tests in separate files under `test/functions`.
|
||||
### Installation
|
||||
|
||||
## Segment Tests
|
||||
In order to execute the tests you need to install `shunit2`, which is a
|
||||
submodule. To install the submodule, you can execute
|
||||
`git submodule init && git submodule update`.
|
||||
|
||||
These Tests tend to be more complex in setup than the basic tests. To avoid ending
|
||||
up in a huge single file, there is one file per segment in `test/segments`.
|
||||
### Executing tests
|
||||
|
||||
# Manual Testing
|
||||
The tests are shell scripts on their own. So you can execute them right away.
|
||||
To execute all tests you could just execute `./test/suite.spec`.
|
||||
|
||||
### General Test Structure
|
||||
|
||||
The tests usually have a `setUp()` function which is executed before every
|
||||
test function. Speaking of, test functions must be prefixed with `test`. In
|
||||
the tests, you can do [different Assertions](https://github.com/kward/shunit2#-asserts).
|
||||
It is always a good idea to mock the program you want to test (just have a
|
||||
look at other tests), so that the testrunner does not have to have all
|
||||
programs installed.
|
||||
|
||||
### Travis
|
||||
|
||||
We use [Travis](https://travis-ci.org/) for Continuous Integration. This
|
||||
service executes our tests after every push. For now, we need to tell travis
|
||||
where to find the tests, which is what happens in the `.travis.yml` file.
|
||||
|
||||
## Manual Testing
|
||||
|
||||
If unit tests are not sufficient (e.g. you have an issue with your prompt that
|
||||
occurs only in a specific ZSH framework) then you can use either Docker or
|
||||
or our Vagrant.
|
||||
|
||||
## Docker
|
||||
### Docker
|
||||
|
||||
This is the easiest to use _if_ you have Docker already installed and running.
|
||||
|
||||
@@ -42,7 +62,7 @@ You can get Docker at <https://www.docker.com/community-edition>.
|
||||
|
||||
**Note:** Not all frameworks work with all versions of ZSH (or the underlying OS).
|
||||
|
||||
## Vagrant
|
||||
### Vagrant
|
||||
|
||||
Currently there are two test VMs. `test-vm` is an Ubuntu machine with several
|
||||
pre-installed ZSH frameworks. And there is `test-bsd-vm` which is a FreeBSD!
|
||||
|
@@ -1,111 +1,236 @@
|
||||
#!/usr/bin/env zsh
|
||||
#vim:ft=zsh ts=2 sw=2 sts=2 et fenc=utf-8
|
||||
|
||||
source functions/colors.zsh
|
||||
source functions/icons.zsh
|
||||
source functions/utilities.zsh
|
||||
# Map our $OS to neofetch $os
|
||||
os="$OS"
|
||||
|
||||
|
||||
trim() {
|
||||
set -f
|
||||
# shellcheck disable=2048,2086
|
||||
set -- $*
|
||||
printf '%s\n' "${*//[[:space:]]/}"
|
||||
set +f
|
||||
}
|
||||
|
||||
get_ppid() {
|
||||
# Get parent process ID of PID.
|
||||
case "$os" in
|
||||
"Windows")
|
||||
ppid="$(ps -p "${1:-$PPID}" | awk '{printf $2}')"
|
||||
ppid="${ppid/PPID}"
|
||||
;;
|
||||
|
||||
"Linux")
|
||||
ppid="$(grep -i -F "PPid:" "/proc/${1:-$PPID}/status")"
|
||||
ppid="$(trim "${ppid/PPid:}")"
|
||||
;;
|
||||
|
||||
*)
|
||||
ppid="$(ps -p "${1:-$PPID}" -o ppid=)"
|
||||
;;
|
||||
esac
|
||||
|
||||
printf "%s" "$ppid"
|
||||
}
|
||||
|
||||
get_process_name() {
|
||||
# Get PID name.
|
||||
case "$os" in
|
||||
"Windows")
|
||||
name="$(ps -p "${1:-$PPID}" | awk '{printf $8}')"
|
||||
name="${name/COMMAND}"
|
||||
name="${name/*\/}"
|
||||
;;
|
||||
|
||||
"Linux")
|
||||
name="$(< "/proc/${1:-$PPID}/comm")"
|
||||
;;
|
||||
|
||||
*)
|
||||
name="$(ps -p "${1:-$PPID}" -o comm=)"
|
||||
;;
|
||||
esac
|
||||
|
||||
printf "%s" "$name"
|
||||
}
|
||||
|
||||
# Taken from NeoFetch (slightly modified)
|
||||
get_term() {
|
||||
local term
|
||||
|
||||
# If function was run, stop here.
|
||||
#((term_run == 1)) && return
|
||||
# ((term_run == 1)) && return
|
||||
|
||||
# Workaround for macOS systems that
|
||||
# don't support the block below.
|
||||
case "$TERM_PROGRAM" in
|
||||
"iTerm.app") term="iTerm2" ;;
|
||||
"iTerm.app") term="iTerm2" ;;
|
||||
"Terminal.app") term="Apple Terminal" ;;
|
||||
"Hyper") term="HyperTerm" ;;
|
||||
*) term="${TERM_PROGRAM/\.app}" ;;
|
||||
"Hyper") term="HyperTerm" ;;
|
||||
*) term="${TERM_PROGRAM/\.app}" ;;
|
||||
esac
|
||||
|
||||
# Most likely TosWin2 on FreeMiNT - quick check
|
||||
[[ "$TERM" == "tw52" || "$TERM" == "tw100" ]] && \
|
||||
term="TosWin2"
|
||||
|
||||
[[ "$SSH_CONNECTION" ]] && \
|
||||
term="$SSH_TTY"
|
||||
|
||||
# Check $PPID for terminal emulator.
|
||||
while [[ -z "$term" ]]; do
|
||||
parent="$(get_ppid "$parent")"
|
||||
[[ -z "$parent" ]] && break
|
||||
name="$(get_process_name "$parent")"
|
||||
|
||||
case "${name// }" in
|
||||
"${SHELL/*\/}" | *"sh" | "tmux"* | "screen" | "su"*) ;;
|
||||
"login"* | *"Login"* | "init" | "(init)") term="$(tty)" ;;
|
||||
"ruby" | "1" | "systemd" | "sshd"* | "python"* | "USER"*"PID"*) break ;;
|
||||
"${SHELL/*\/}"|*"sh"|"screen"|"su"*) ;;
|
||||
|
||||
"login"*|*"Login"*|"init"|"(init)")
|
||||
term="$(tty)"
|
||||
;;
|
||||
|
||||
"ruby"|"1"|"tmux"*|"systemd"|"sshd"*|"python"*|"USER"*"PID"*|"kdeinit"*|"launchd"*)
|
||||
break
|
||||
;;
|
||||
|
||||
"gnome-terminal-") term="gnome-terminal" ;;
|
||||
*) term="${name##*/}" ;;
|
||||
"urxvtd") term="urxvt" ;;
|
||||
*"nvim") term="Neovim Terminal" ;;
|
||||
*"NeoVimServer"*) term="VimR Terminal" ;;
|
||||
*) term="${name##*/}" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Log that the function was run.
|
||||
#term_run=1
|
||||
# term_run=1
|
||||
|
||||
echo "${term}"
|
||||
}
|
||||
|
||||
get_term_font() {
|
||||
local term="${1}"
|
||||
#((term_run != 1)) && get_term
|
||||
# ((term_run != 1)) && get_term
|
||||
|
||||
case "$term" in
|
||||
"alacritty"*)
|
||||
term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${XDG_CONFIG_HOME}/alacritty/alacritty.yml")"
|
||||
shopt -s nullglob
|
||||
confs=({$XDG_CONFIG_HOME,$HOME}/{alacritty,}/{.,}alacritty.ym?)
|
||||
shopt -u nullglob
|
||||
|
||||
[[ -f "${confs[0]}" ]] || return
|
||||
|
||||
term_font="$(awk -F ':|#' '/normal:/ {getline; print}' "${confs[0]}")"
|
||||
term_font="${term_font/*family:}"
|
||||
term_font="${term_font/$'\n'*}"
|
||||
term_font="${term_font/\#*}"
|
||||
;;
|
||||
|
||||
"Apple_Terminal")
|
||||
term_font="$(osascript -e 'tell application "Terminal" to font name of window frontmost')"
|
||||
term_font="$(osascript <<END
|
||||
tell application "Terminal" to font name of window frontmost
|
||||
END
|
||||
)"
|
||||
;;
|
||||
|
||||
"iTerm2")
|
||||
# Unfortunately the profile name is not unique, but it seems to be the only thing
|
||||
# that identifies an active profile. There is the "id of current session of current window"
|
||||
# thou, but that does not match to a guid in the plist.
|
||||
# So, be warned! Collisions may occur!
|
||||
# that identifies an active profile. There is the "id of current session of current win-
|
||||
# dow" though, but that does not match to a guid in the plist.
|
||||
# So, be warned, collisions may occur!
|
||||
# See: https://groups.google.com/forum/#!topic/iterm2-discuss/0tO3xZ4Zlwg
|
||||
# and: https://gitlab.com/gnachman/iterm2/issues/5586
|
||||
local currentProfileName=$(osascript -e 'tell application "iTerm2" to profile name of current session of current window')
|
||||
local current_profile_name profiles_count profile_name diff_font
|
||||
|
||||
current_profile_name="$(osascript <<END
|
||||
tell application "iTerm2" to profile name \
|
||||
of current session of current window
|
||||
END
|
||||
)"
|
||||
|
||||
# Warning: Dynamic profiles are not taken into account here!
|
||||
# https://www.iterm2.com/documentation-dynamic-profiles.html
|
||||
font_file="${HOME}/Library/Preferences/com.googlecode.iterm2.plist"
|
||||
|
||||
local nonAsciiFont
|
||||
|
||||
# Count Guids in "New Bookmarks"; they should be unique
|
||||
local profilesCount=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null | grep -c "Guid")
|
||||
for idx in $(seq 0 "${profilesCount}"); do
|
||||
local profileName=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Name:" ~/Library/Preferences/com.googlecode.iterm2.plist 2>/dev/null)
|
||||
if [[ "${profileName}" == "${currentProfileName}" ]]; then
|
||||
profiles_count="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:'" "$font_file" | \
|
||||
grep -w -c "Guid")"
|
||||
|
||||
for ((i=0; i<profiles_count; i++)); do
|
||||
profile_name="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Name:'" "$font_file")"
|
||||
|
||||
if [[ "$profile_name" == "$current_profile_name" ]]; then
|
||||
# "Normal Font"
|
||||
term_font=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Normal\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
|
||||
|
||||
term_font="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Normal Font:'" \
|
||||
"$font_file")"
|
||||
|
||||
# Font for non-ascii characters
|
||||
# Only check for a different non-ascii font, if the user checked
|
||||
# the "use a different font for non-ascii text" switch.
|
||||
local useDifferentFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Use\ Non-ASCII\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
|
||||
if [[ "$useDifferentFont" == "true" ]]; then
|
||||
local nonAsciiFont=$(/usr/libexec/PlistBuddy -c "Print :New\ Bookmarks:${idx}:Non\ Ascii\ Font:" ~/Library/Preferences/com.googlecode.iterm2.plist)
|
||||
if [[ "$term_font" != "$nonAsciiFont" ]]; then
|
||||
term_font="$term_font (normal) / $nonAsciiFont (non-ascii)"
|
||||
fi
|
||||
diff_font="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Use Non-ASCII Font:'" \
|
||||
"$font_file")"
|
||||
|
||||
if [[ "$diff_font" == "true" ]]; then
|
||||
non_ascii="$(/usr/libexec/PlistBuddy -c "Print ':New Bookmarks:${i}:Non Ascii Font:'" \
|
||||
"$font_file")"
|
||||
|
||||
[[ "$term_font" != "$non_ascii" ]] && \
|
||||
term_font="$term_font (normal) / $non_ascii (non-ascii)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
;;
|
||||
|
||||
"deepin-terminal"*)
|
||||
term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END{print a " " b}' "${XDG_CONFIG_HOME}/deepin/deepin-terminal/config.conf")"
|
||||
term_font="$(awk -F '=' '/font=/ {a=$2} /font_size/ {b=$2} END {print a " " b}' \
|
||||
"${XDG_CONFIG_HOME}/deepin/deepin-terminal/config.conf")"
|
||||
;;
|
||||
|
||||
"GNUstep_Terminal")
|
||||
term_font="$(awk -F '>|<' '/>TerminalFont</ {getline; f=$3}
|
||||
/>TerminalFontSize</ {getline; s=$3} END {print f " " s}' \
|
||||
"${HOME}/GNUstep/Defaults/Terminal.plist")"
|
||||
;;
|
||||
|
||||
"Hyper"*)
|
||||
term_font="$(awk -F "," '/fontFamily/ {a=$1} END{print a}' "${HOME}/.hyper.js" | awk -F "'" '{a=$2} END{print a}')"
|
||||
term_font="$(awk -F':|,' '/fontFamily/ {print $2; exit}' "${HOME}/.hyper.js")"
|
||||
term_font="$(trim_quotes "$term_font")"
|
||||
;;
|
||||
|
||||
"kitty"*)
|
||||
shopt -s nullglob
|
||||
confs=({$KITTY_CONFIG_DIRECTORY,$XDG_CONFIG_HOME,~/Library/Preferences}/kitty/kitty.con?)
|
||||
shopt -u nullglob
|
||||
|
||||
[[ -f "${confs[0]}" ]] || return
|
||||
|
||||
term_font="$(awk '/^([[:space:]]*|[^#_])font_family[[:space:]]+/ {
|
||||
$1 = "";
|
||||
gsub(/^[[:space:]]/, "");
|
||||
font = $0
|
||||
}
|
||||
/^([[:space:]]*|[^#_])font_size[[:space:]]+/ {
|
||||
size = $2
|
||||
}
|
||||
END { print font " " size}' "${confs[0]}")"
|
||||
;;
|
||||
|
||||
"konsole"*)
|
||||
# Get Process ID of current konsole window / tab
|
||||
child="$(get_ppid "$$")"
|
||||
|
||||
konsole_instances=($(qdbus | grep 'org.kde.konsole'))
|
||||
IFS=$'\n' read -d "" -ra konsole_instances < <(qdbus | grep -F 'org.kde.konsole')
|
||||
|
||||
for i in "${konsole_instances[@]}"; do
|
||||
konsole_sessions=($(qdbus "${i}" | grep '/Sessions/'))
|
||||
IFS=$'\n' read -d "" -ra konsole_sessions < <(qdbus "$i" | grep -F '/Sessions/')
|
||||
|
||||
for session in "${konsole_sessions[@]}"; do
|
||||
if ((child == "$(qdbus "${i}" "${session}" processId)")); then
|
||||
profile="$(qdbus "${i}" "${session}" environment | awk -F '=' '/KONSOLE_PROFILE_NAME/ {print $2}')"
|
||||
if ((child == "$(qdbus "$i" "$session" processId)")); then
|
||||
profile="$(qdbus "$i" "$session" environment |\
|
||||
awk -F '=' '/KONSOLE_PROFILE_NAME/ {print $2}')"
|
||||
break
|
||||
fi
|
||||
done
|
||||
@@ -113,9 +238,53 @@ get_term_font() {
|
||||
done
|
||||
|
||||
# We could have two profile files for the same profile name, take first match
|
||||
profile_filename="$(grep -l "Name=${profile}" "${HOME}"/.local/share/konsole/*.profile)"
|
||||
profile_filename="$(grep -l "Name=${profile}" "$HOME"/.local/share/konsole/*.profile)"
|
||||
profile_filename="${profile_filename/$'\n'*}"
|
||||
[[ "$profile_filename" ]] && term_font="$(awk -F '=|,' '/Font=/ {print $2 " " $3}' "$profile_filename")"
|
||||
|
||||
[[ "$profile_filename" ]] && \
|
||||
term_font="$(awk -F '=|,' '/Font=/ {print $2 " " $3}' "$profile_filename")"
|
||||
;;
|
||||
|
||||
"lxterminal"*)
|
||||
term_font="$(awk -F '=' '/fontname=/ {print $2; exit}' \
|
||||
"${XDG_CONFIG_HOME}/lxterminal/lxterminal.conf")"
|
||||
;;
|
||||
|
||||
"mate-terminal")
|
||||
# To get the actual config we have to create a temporarily file with the
|
||||
# --save-config option.
|
||||
mateterm_config="/tmp/mateterm.cfg"
|
||||
|
||||
# Ensure /tmp exists and we do not overwrite anything.
|
||||
if [[ -d /tmp && ! -f "$mateterm_config" ]]; then
|
||||
mate-terminal --save-config="$mateterm_config"
|
||||
|
||||
role="$(xprop -id "${WINDOWID}" WM_WINDOW_ROLE)"
|
||||
role="${role##* }"
|
||||
role="${role//\"}"
|
||||
|
||||
profile="$(awk -F '=' -v r="$role" \
|
||||
'$0~r {
|
||||
getline;
|
||||
if(/Maximized/) getline;
|
||||
if(/Fullscreen/) getline;
|
||||
id=$2"]"
|
||||
} $0~id {if(id) {getline; print $2; exit}}' \
|
||||
"$mateterm_config")"
|
||||
|
||||
rm -f "$mateterm_config"
|
||||
|
||||
mate_get() {
|
||||
gsettings get org.mate.terminal.profile:/org/mate/terminal/profiles/"$1"/ "$2"
|
||||
}
|
||||
|
||||
if [[ "$(mate_get "$profile" "use-system-font")" == "true" ]]; then
|
||||
term_font="$(gsettings get org.mate.interface monospace-font-name)"
|
||||
else
|
||||
term_font="$(mate_get "$profile" "font")"
|
||||
fi
|
||||
term_font="$(trim_quotes "$term_font")"
|
||||
fi
|
||||
;;
|
||||
|
||||
"mintty")
|
||||
@@ -124,30 +293,91 @@ get_term_font() {
|
||||
|
||||
"pantheon"*)
|
||||
term_font="$(gsettings get org.pantheon.terminal.settings font)"
|
||||
[[ -z "${term_font//\'}" ]] && term_font="$(gsettings get org.gnome.desktop.interface monospace-font-name)"
|
||||
|
||||
[[ -z "${term_font//\'}" ]] && \
|
||||
term_font="$(gsettings get org.gnome.desktop.interface monospace-font-name)"
|
||||
|
||||
term_font="$(trim_quotes "$term_font")"
|
||||
;;
|
||||
|
||||
"qterminal")
|
||||
term_font="$(awk -F '=' '/fontFamily=/ {a=$2} /fontSize=/ {b=$2} END {print a " " b}' \
|
||||
"${XDG_CONFIG_HOME}/qterminal.org/qterminal.ini")"
|
||||
;;
|
||||
|
||||
"sakura"*)
|
||||
term_font="$(awk -F '=' '/^font=/ {a=$2} END{print a}' "${XDG_CONFIG_HOME}/sakura/sakura.conf")"
|
||||
term_font="$(awk -F '=' '/^font=/ {print $2; exit}' \
|
||||
"${XDG_CONFIG_HOME}/sakura/sakura.conf")"
|
||||
;;
|
||||
|
||||
"st")
|
||||
term_font="$(ps -o command= -p "$parent" | grep -F -- "-f")"
|
||||
|
||||
if [[ "$term_font" ]]; then
|
||||
term_font="${term_font/*-f/}"
|
||||
term_font="${term_font/ -*/}"
|
||||
|
||||
else
|
||||
# On Linux we can get the exact path to the running binary through the procfs
|
||||
# (in case `st` is launched from outside of $PATH) on other systems we just
|
||||
# have to guess and assume `st` is invoked from somewhere in the users $PATH
|
||||
[[ -L /proc/$parent/exe ]] && binary="/proc/$parent/exe" || binary="$(type -p st)"
|
||||
|
||||
# Grep the output of strings on the `st` binary for anything that looks vaguely
|
||||
# like a font definition. NOTE: There is a slight limitation in this approach.
|
||||
# Technically "Font Name" is a valid font. As it doesn't specify any font options
|
||||
# though it is hard to match it correctly amongst the rest of the noise.
|
||||
[[ -n "$binary" ]] && \
|
||||
term_font="$(strings "$binary" | grep -F -m 1 \
|
||||
-e "pixelsize=" \
|
||||
-e "size=" \
|
||||
-e "antialias=" \
|
||||
-e "autohint=")"
|
||||
fi
|
||||
|
||||
term_font="${term_font/xft:}"
|
||||
term_font="${term_font/:*}"
|
||||
;;
|
||||
|
||||
"terminology")
|
||||
term_font="$(strings "${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg" | awk '/^font\.name$/{print a}{a=$0}')"
|
||||
term_font="$(strings "${XDG_CONFIG_HOME}/terminology/config/standard/base.cfg" |\
|
||||
awk '/^font\.name$/{print a}{a=$0}')"
|
||||
term_font="${term_font/.pcf}"
|
||||
term_font="${term_font/:*}"
|
||||
;;
|
||||
|
||||
"termite")
|
||||
[[ -f "${XDG_CONFIG_HOME}/termite/config" ]] && termite_config="${XDG_CONFIG_HOME}/termite/config"
|
||||
term_font="$(awk -F '= ' '/\[options\]/ {opt=1} /^font/ {if(opt==1) a=$2; opt=0} END{print a}' "/etc/xdg/termite/config" "$termite_config")"
|
||||
[[ -f "${XDG_CONFIG_HOME}/termite/config" ]] && \
|
||||
termite_config="${XDG_CONFIG_HOME}/termite/config"
|
||||
|
||||
term_font="$(awk -F '= ' '/\[options\]/ {
|
||||
opt=1
|
||||
}
|
||||
/^\s*font/ {
|
||||
if(opt==1) a=$2;
|
||||
opt=0
|
||||
} END {print a}' "/etc/xdg/termite/config" \
|
||||
"$termite_config")"
|
||||
;;
|
||||
|
||||
"urxvt" | "urxvtd" | "rxvt-unicode" | "xterm")
|
||||
term_font="$(grep -i -F "${term/d}*font" < <(xrdb -query))"
|
||||
term_font="${term_font/*font:}"
|
||||
xrdb="$(xrdb -query)"
|
||||
term_font="$(grep -im 1 -e "^${term/d}"'\**\.*font' -e '^\*font' <<< "$xrdb")"
|
||||
term_font="${term_font/*"*font:"}"
|
||||
term_font="${term_font/*".font:"}"
|
||||
term_font="${term_font/*"*.font:"}"
|
||||
term_font="$(trim "$term_font")"
|
||||
|
||||
[[ -z "$term_font" && "$term" == "xterm" ]] && \
|
||||
term_font="$(grep '^XTerm.vt100.faceName' <<< "$xrdb")"
|
||||
|
||||
term_font="$(trim "${term_font/*"faceName:"}")"
|
||||
|
||||
# xft: isn't required at the beginning so we prepend it if it's missing
|
||||
[[ "${term_font:0:1}" != "-" && \
|
||||
"${term_font:0:4}" != "xft:" ]] && \
|
||||
term_font="xft:$term_font"
|
||||
|
||||
# Xresources has two different font formats, this checks which
|
||||
# one is in use and formats it accordingly.
|
||||
case "$term_font" in
|
||||
@@ -156,12 +386,23 @@ get_term_font() {
|
||||
term_font="${term_font/:*}"
|
||||
;;
|
||||
|
||||
"-"*) term_font="$(awk -F '\\-' '{printf $3}' <<< "$term_font")" ;;
|
||||
"-"*)
|
||||
IFS=- read -r _ _ term_font _ <<< "$term_font"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
|
||||
"xfce4-terminal")
|
||||
term_font="$(awk -F '=' '/^FontName/ {a=$2} END{print a}' "${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")"
|
||||
term_font="$(awk -F '=' '/^FontName/{a=$2}/^FontUseSystem=TRUE/{a=$0} END {print a}' \
|
||||
"${XDG_CONFIG_HOME}/xfce4/terminal/terminalrc")"
|
||||
|
||||
[[ "$term_font" == "FontUseSystem=TRUE" ]] && \
|
||||
term_font="$(gsettings get org.gnome.desktop.interface monospace-font-name)"
|
||||
|
||||
term_font="$(trim_quotes "$term_font")"
|
||||
|
||||
# Default fallback font hardcoded in terminal-preferences.c
|
||||
[[ -z "$term_font" ]] && term_font="Monospace 12"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@@ -6,7 +6,7 @@ RUN \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh \
|
||||
zsh=5.0.2-3ubuntu6.2 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
|
@@ -6,7 +6,7 @@ RUN \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh \
|
||||
zsh=5.1.1-1ubuntu2.2 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
|
@@ -1,4 +1,4 @@
|
||||
FROM ubuntu:17.04
|
||||
FROM ubuntu:17.10
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
@@ -6,7 +6,7 @@ RUN \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh \
|
||||
zsh=5.2-5ubuntu1.2 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
|
40
.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.3.1/Dockerfile
vendored
Normal file
40
.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.3.1/Dockerfile
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
FROM debian:stretch
|
||||
|
||||
# We switched here to debian, as there seems no ZSH 5.3 in ubuntu.
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh=5.3.1-4+b2 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
jq \
|
||||
nodejs \
|
||||
ruby \
|
||||
python \
|
||||
python-virtualenv \
|
||||
sudo \
|
||||
locales
|
||||
|
||||
RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred
|
||||
# Locale generation is different in debian. We need to enable en_US
|
||||
# locale and then regenerate locales.
|
||||
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
|
||||
RUN locale-gen "en_US.UTF-8"
|
||||
|
||||
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||
|
||||
USER fred
|
||||
WORKDIR /home/fred
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV TERM=xterm-256color
|
||||
ENV DEFAULT_USER=fred
|
||||
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||
|
||||
RUN touch .zshrc
|
||||
|
||||
CMD ["/bin/zsh", "-l"]
|
35
.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.4.2/Dockerfile
vendored
Normal file
35
.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.4.2/Dockerfile
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
FROM ubuntu:18.04
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh=5.4.2-3ubuntu3 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
jq \
|
||||
nodejs \
|
||||
ruby \
|
||||
python \
|
||||
python-virtualenv \
|
||||
sudo \
|
||||
locales
|
||||
|
||||
RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred
|
||||
RUN locale-gen "en_US.UTF-8"
|
||||
|
||||
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||
|
||||
USER fred
|
||||
WORKDIR /home/fred
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV TERM=xterm-256color
|
||||
ENV DEFAULT_USER=fred
|
||||
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||
|
||||
RUN touch .zshrc
|
||||
|
||||
CMD ["/bin/zsh", "-l"]
|
35
.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.5.1/Dockerfile
vendored
Normal file
35
.zprezto/modules/prompt/external/powerlevel9k/docker/base-5.5.1/Dockerfile
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
FROM ubuntu:18.10
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
echo 'golang-go golang-go/dashboard boolean false' | debconf-set-selections && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
curl \
|
||||
git \
|
||||
zsh=5.5.1-1ubuntu1 \
|
||||
mercurial \
|
||||
subversion \
|
||||
golang \
|
||||
jq \
|
||||
nodejs \
|
||||
ruby \
|
||||
python \
|
||||
python-virtualenv \
|
||||
sudo \
|
||||
locales
|
||||
|
||||
RUN adduser --shell /bin/zsh --gecos 'fred' --disabled-password fred
|
||||
RUN locale-gen "en_US.UTF-8"
|
||||
|
||||
COPY docker/fred-sudoers /etc/sudoers.d/fred
|
||||
|
||||
USER fred
|
||||
WORKDIR /home/fred
|
||||
ENV LANG=en_US.UTF-8
|
||||
ENV TERM=xterm-256color
|
||||
ENV DEFAULT_USER=fred
|
||||
ENV POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=true
|
||||
|
||||
RUN touch .zshrc
|
||||
|
||||
CMD ["/bin/zsh", "-l"]
|
@@ -9,7 +9,7 @@ for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do
|
||||
ln -nsf "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"
|
||||
done
|
||||
|
||||
ln -s "${HOME}/p9k/powerlevel9k.zsh-theme" \
|
||||
ln -snf "${HOME}/p9k/powerlevel9k.zsh-theme" \
|
||||
"${HOME}/.zprezto/modules/prompt/functions/prompt_powerlevel9k_setup"
|
||||
|
||||
echo "zstyle ':prezto:module:prompt' theme 'powerlevel9k'" \
|
||||
|
7
.zprezto/modules/prompt/external/powerlevel9k/docker/zshing/Dockerfile
vendored
Normal file
7
.zprezto/modules/prompt/external/powerlevel9k/docker/zshing/Dockerfile
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
ARG base
|
||||
FROM p9k:${base}
|
||||
|
||||
COPY docker/zshing/install.zsh /tmp/
|
||||
RUN zsh /tmp/install.zsh
|
||||
|
||||
COPY ./ p9k/
|
16
.zprezto/modules/prompt/external/powerlevel9k/docker/zshing/install.zsh
vendored
Normal file
16
.zprezto/modules/prompt/external/powerlevel9k/docker/zshing/install.zsh
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
#!zsh
|
||||
|
||||
# install zshing https://github.com/zakariaGatter/zshing
|
||||
git clone https://github.com/zakariaGatter/zshing.git ~/.zshing/zshing
|
||||
|
||||
# Link P9K in zshing directory
|
||||
ln -nsf ~/p9k ~/.zshing/powerlevel9k
|
||||
|
||||
{
|
||||
echo
|
||||
echo 'ZSHING_PLUGINS=(
|
||||
"bhilburn/powerlevel9k"
|
||||
)'
|
||||
echo
|
||||
echo "source ~/.zshing/zshing/zshing.zsh"
|
||||
} >> ~/.zshrc
|
@@ -6,6 +6,270 @@
|
||||
# https://github.com/bhilburn/powerlevel9k
|
||||
################################################################
|
||||
|
||||
typeset -gAh __P9K_COLORS
|
||||
# https://jonasjacek.github.io/colors/
|
||||
# use color names by default to allow dark/light themes to adjust colors based on names
|
||||
__P9K_COLORS=(
|
||||
black 000
|
||||
red 001
|
||||
green 002
|
||||
yellow 003
|
||||
blue 004
|
||||
magenta 005
|
||||
cyan 006
|
||||
white 007
|
||||
grey 008
|
||||
maroon 009
|
||||
lime 010
|
||||
olive 011
|
||||
navy 012
|
||||
fuchsia 013
|
||||
purple 013
|
||||
aqua 014
|
||||
teal 014
|
||||
silver 015
|
||||
grey0 016
|
||||
navyblue 017
|
||||
darkblue 018
|
||||
blue3 019
|
||||
blue3 020
|
||||
blue1 021
|
||||
darkgreen 022
|
||||
deepskyblue4 023
|
||||
deepskyblue4 024
|
||||
deepskyblue4 025
|
||||
dodgerblue3 026
|
||||
dodgerblue2 027
|
||||
green4 028
|
||||
springgreen4 029
|
||||
turquoise4 030
|
||||
deepskyblue3 031
|
||||
deepskyblue3 032
|
||||
dodgerblue1 033
|
||||
green3 034
|
||||
springgreen3 035
|
||||
darkcyan 036
|
||||
lightseagreen 037
|
||||
deepskyblue2 038
|
||||
deepskyblue1 039
|
||||
green3 040
|
||||
springgreen3 041
|
||||
springgreen2 042
|
||||
cyan3 043
|
||||
darkturquoise 044
|
||||
turquoise2 045
|
||||
green1 046
|
||||
springgreen2 047
|
||||
springgreen1 048
|
||||
mediumspringgreen 049
|
||||
cyan2 050
|
||||
cyan1 051
|
||||
darkred 052
|
||||
deeppink4 053
|
||||
purple4 054
|
||||
purple4 055
|
||||
purple3 056
|
||||
blueviolet 057
|
||||
orange4 058
|
||||
grey37 059
|
||||
mediumpurple4 060
|
||||
slateblue3 061
|
||||
slateblue3 062
|
||||
royalblue1 063
|
||||
chartreuse4 064
|
||||
darkseagreen4 065
|
||||
paleturquoise4 066
|
||||
steelblue 067
|
||||
steelblue3 068
|
||||
cornflowerblue 069
|
||||
chartreuse3 070
|
||||
darkseagreen4 071
|
||||
cadetblue 072
|
||||
cadetblue 073
|
||||
skyblue3 074
|
||||
steelblue1 075
|
||||
chartreuse3 076
|
||||
palegreen3 077
|
||||
seagreen3 078
|
||||
aquamarine3 079
|
||||
mediumturquoise 080
|
||||
steelblue1 081
|
||||
chartreuse2 082
|
||||
seagreen2 083
|
||||
seagreen1 084
|
||||
seagreen1 085
|
||||
aquamarine1 086
|
||||
darkslategray2 087
|
||||
darkred 088
|
||||
deeppink4 089
|
||||
darkmagenta 090
|
||||
darkmagenta 091
|
||||
darkviolet 092
|
||||
purple 093
|
||||
orange4 094
|
||||
lightpink4 095
|
||||
plum4 096
|
||||
mediumpurple3 097
|
||||
mediumpurple3 098
|
||||
slateblue1 099
|
||||
yellow4 100
|
||||
wheat4 101
|
||||
grey53 102
|
||||
lightslategrey 103
|
||||
mediumpurple 104
|
||||
lightslateblue 105
|
||||
yellow4 106
|
||||
darkolivegreen3 107
|
||||
darkseagreen 108
|
||||
lightskyblue3 109
|
||||
lightskyblue3 110
|
||||
skyblue2 111
|
||||
chartreuse2 112
|
||||
darkolivegreen3 113
|
||||
palegreen3 114
|
||||
darkseagreen3 115
|
||||
darkslategray3 116
|
||||
skyblue1 117
|
||||
chartreuse1 118
|
||||
lightgreen 119
|
||||
lightgreen 120
|
||||
palegreen1 121
|
||||
aquamarine1 122
|
||||
darkslategray1 123
|
||||
red3 124
|
||||
deeppink4 125
|
||||
mediumvioletred 126
|
||||
magenta3 127
|
||||
darkviolet 128
|
||||
purple 129
|
||||
darkorange3 130
|
||||
indianred 131
|
||||
hotpink3 132
|
||||
mediumorchid3 133
|
||||
mediumorchid 134
|
||||
mediumpurple2 135
|
||||
darkgoldenrod 136
|
||||
lightsalmon3 137
|
||||
rosybrown 138
|
||||
grey63 139
|
||||
mediumpurple2 140
|
||||
mediumpurple1 141
|
||||
gold3 142
|
||||
darkkhaki 143
|
||||
navajowhite3 144
|
||||
grey69 145
|
||||
lightsteelblue3 146
|
||||
lightsteelblue 147
|
||||
yellow3 148
|
||||
darkolivegreen3 149
|
||||
darkseagreen3 150
|
||||
darkseagreen2 151
|
||||
lightcyan3 152
|
||||
lightskyblue1 153
|
||||
greenyellow 154
|
||||
darkolivegreen2 155
|
||||
palegreen1 156
|
||||
darkseagreen2 157
|
||||
darkseagreen1 158
|
||||
paleturquoise1 159
|
||||
red3 160
|
||||
deeppink3 161
|
||||
deeppink3 162
|
||||
magenta3 163
|
||||
magenta3 164
|
||||
magenta2 165
|
||||
darkorange3 166
|
||||
indianred 167
|
||||
hotpink3 168
|
||||
hotpink2 169
|
||||
orchid 170
|
||||
mediumorchid1 171
|
||||
orange3 172
|
||||
lightsalmon3 173
|
||||
lightpink3 174
|
||||
pink3 175
|
||||
plum3 176
|
||||
violet 177
|
||||
gold3 178
|
||||
lightgoldenrod3 179
|
||||
tan 180
|
||||
mistyrose3 181
|
||||
thistle3 182
|
||||
plum2 183
|
||||
yellow3 184
|
||||
khaki3 185
|
||||
lightgoldenrod2 186
|
||||
lightyellow3 187
|
||||
grey84 188
|
||||
lightsteelblue1 189
|
||||
yellow2 190
|
||||
darkolivegreen1 191
|
||||
darkolivegreen1 192
|
||||
darkseagreen1 193
|
||||
honeydew2 194
|
||||
lightcyan1 195
|
||||
red1 196
|
||||
deeppink2 197
|
||||
deeppink1 198
|
||||
deeppink1 199
|
||||
magenta2 200
|
||||
magenta1 201
|
||||
orangered1 202
|
||||
indianred1 203
|
||||
indianred1 204
|
||||
hotpink 205
|
||||
hotpink 206
|
||||
mediumorchid1 207
|
||||
darkorange 208
|
||||
salmon1 209
|
||||
lightcoral 210
|
||||
palevioletred1 211
|
||||
orchid2 212
|
||||
orchid1 213
|
||||
orange1 214
|
||||
sandybrown 215
|
||||
lightsalmon1 216
|
||||
lightpink1 217
|
||||
pink1 218
|
||||
plum1 219
|
||||
gold1 220
|
||||
lightgoldenrod2 221
|
||||
lightgoldenrod2 222
|
||||
navajowhite1 223
|
||||
mistyrose1 224
|
||||
thistle1 225
|
||||
yellow1 226
|
||||
lightgoldenrod1 227
|
||||
khaki1 228
|
||||
wheat1 229
|
||||
cornsilk1 230
|
||||
grey100 231
|
||||
grey3 232
|
||||
grey7 233
|
||||
grey11 234
|
||||
grey15 235
|
||||
grey19 236
|
||||
grey23 237
|
||||
grey27 238
|
||||
grey30 239
|
||||
grey35 240
|
||||
grey39 241
|
||||
grey42 242
|
||||
grey46 243
|
||||
grey50 244
|
||||
grey54 245
|
||||
grey58 246
|
||||
grey62 247
|
||||
grey66 248
|
||||
grey70 249
|
||||
grey74 250
|
||||
grey78 251
|
||||
grey82 252
|
||||
grey85 253
|
||||
grey89 254
|
||||
grey93 255
|
||||
)
|
||||
|
||||
function termColors() {
|
||||
if [[ $POWERLEVEL9K_IGNORE_TERM_COLORS == true ]]; then
|
||||
return
|
||||
@@ -28,339 +292,56 @@ function termColors() {
|
||||
|
||||
# get the proper color code if it does not exist as a name.
|
||||
function getColor() {
|
||||
# no need to check numerical values
|
||||
if [[ "$1" = <-> ]]; then
|
||||
if [[ "$1" = <8-15> ]]; then
|
||||
1=$(($1 - 8))
|
||||
fi
|
||||
else
|
||||
# named color added to parameter expansion print -P to test if the name exists in terminal
|
||||
local named="%K{$1}"
|
||||
# https://misc.flogisoft.com/bash/tip_colors_and_formatting
|
||||
local default="$'\033'\[49m"
|
||||
# http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html
|
||||
local quoted=$(printf "%q" $(print -P "$named"))
|
||||
if [[ $quoted = "$'\033'\[49m" && $1 != "black" ]]; then
|
||||
# color not found, so try to get the code
|
||||
1=$(getColorCode $1)
|
||||
fi
|
||||
# If Color is not numerical, try to get the color code.
|
||||
if [[ "$1" != <-> ]]; then
|
||||
1=$(getColorCode $1)
|
||||
fi
|
||||
echo -n "$1"
|
||||
}
|
||||
|
||||
# empty paramenter resets (stops) background color
|
||||
function backgroundColor() {
|
||||
if [[ -z $1 ]]; then
|
||||
echo -n "%k"
|
||||
else
|
||||
echo -n "%K{$(getColor $1)}"
|
||||
fi
|
||||
echo -n "%K{$(getColor $1)}"
|
||||
}
|
||||
|
||||
# empty paramenter resets (stops) foreground color
|
||||
function foregroundColor() {
|
||||
if [[ -z $1 ]]; then
|
||||
echo -n "%f"
|
||||
else
|
||||
echo -n "%F{$(getColor $1)}"
|
||||
fi
|
||||
echo -n "%F{$(getColor $1)}"
|
||||
}
|
||||
|
||||
# Get numerical color codes. That way we translate ANSI codes
|
||||
# into ZSH-Style color codes.
|
||||
function getColorCode() {
|
||||
# Check if given value is already numerical
|
||||
if [[ "$1" = <-> ]]; then
|
||||
# ANSI color codes distinguish between "foreground"
|
||||
# and "background" colors. We don't need to do that,
|
||||
# as ZSH uses a 256 color space anyway.
|
||||
if [[ "$1" = <8-15> ]]; then
|
||||
echo -n $(($1 - 8))
|
||||
else
|
||||
echo -n "$1"
|
||||
fi
|
||||
else
|
||||
typeset -A codes
|
||||
# https://jonasjacek.github.io/colors/
|
||||
# use color names by default to allow dark/light themes to adjust colors based on names
|
||||
codes[black]=000
|
||||
codes[maroon]=001
|
||||
codes[green]=002
|
||||
codes[olive]=003
|
||||
codes[navy]=004
|
||||
codes[purple]=005
|
||||
codes[teal]=006
|
||||
codes[silver]=007
|
||||
codes[grey]=008
|
||||
codes[red]=009
|
||||
codes[lime]=010
|
||||
codes[yellow]=011
|
||||
codes[blue]=012
|
||||
codes[fuchsia]=013
|
||||
codes[aqua]=014
|
||||
codes[white]=015
|
||||
codes[grey0]=016
|
||||
codes[navyblue]=017
|
||||
codes[darkblue]=018
|
||||
codes[blue3]=019
|
||||
codes[blue3]=020
|
||||
codes[blue1]=021
|
||||
codes[darkgreen]=022
|
||||
codes[deepskyblue4]=023
|
||||
codes[deepskyblue4]=024
|
||||
codes[deepskyblue4]=025
|
||||
codes[dodgerblue3]=026
|
||||
codes[dodgerblue2]=027
|
||||
codes[green4]=028
|
||||
codes[springgreen4]=029
|
||||
codes[turquoise4]=030
|
||||
codes[deepskyblue3]=031
|
||||
codes[deepskyblue3]=032
|
||||
codes[dodgerblue1]=033
|
||||
codes[green3]=034
|
||||
codes[springgreen3]=035
|
||||
codes[darkcyan]=036
|
||||
codes[lightseagreen]=037
|
||||
codes[deepskyblue2]=038
|
||||
codes[deepskyblue1]=039
|
||||
codes[green3]=040
|
||||
codes[springgreen3]=041
|
||||
codes[springgreen2]=042
|
||||
codes[cyan3]=043
|
||||
codes[darkturquoise]=044
|
||||
codes[turquoise2]=045
|
||||
codes[green1]=046
|
||||
codes[springgreen2]=047
|
||||
codes[springgreen1]=048
|
||||
codes[mediumspringgreen]=049
|
||||
codes[cyan2]=050
|
||||
codes[cyan1]=051
|
||||
codes[darkred]=052
|
||||
codes[deeppink4]=053
|
||||
codes[purple4]=054
|
||||
codes[purple4]=055
|
||||
codes[purple3]=056
|
||||
codes[blueviolet]=057
|
||||
codes[orange4]=058
|
||||
codes[grey37]=059
|
||||
codes[mediumpurple4]=060
|
||||
codes[slateblue3]=061
|
||||
codes[slateblue3]=062
|
||||
codes[royalblue1]=063
|
||||
codes[chartreuse4]=064
|
||||
codes[darkseagreen4]=065
|
||||
codes[paleturquoise4]=066
|
||||
codes[steelblue]=067
|
||||
codes[steelblue3]=068
|
||||
codes[cornflowerblue]=069
|
||||
codes[chartreuse3]=070
|
||||
codes[darkseagreen4]=071
|
||||
codes[cadetblue]=072
|
||||
codes[cadetblue]=073
|
||||
codes[skyblue3]=074
|
||||
codes[steelblue1]=075
|
||||
codes[chartreuse3]=076
|
||||
codes[palegreen3]=077
|
||||
codes[seagreen3]=078
|
||||
codes[aquamarine3]=079
|
||||
codes[mediumturquoise]=080
|
||||
codes[steelblue1]=081
|
||||
codes[chartreuse2]=082
|
||||
codes[seagreen2]=083
|
||||
codes[seagreen1]=084
|
||||
codes[seagreen1]=085
|
||||
codes[aquamarine1]=086
|
||||
codes[darkslategray2]=087
|
||||
codes[darkred]=088
|
||||
codes[deeppink4]=089
|
||||
codes[darkmagenta]=090
|
||||
codes[darkmagenta]=091
|
||||
codes[darkviolet]=092
|
||||
codes[purple]=093
|
||||
codes[orange4]=094
|
||||
codes[lightpink4]=095
|
||||
codes[plum4]=096
|
||||
codes[mediumpurple3]=097
|
||||
codes[mediumpurple3]=098
|
||||
codes[slateblue1]=099
|
||||
codes[yellow4]=100
|
||||
codes[wheat4]=101
|
||||
codes[grey53]=102
|
||||
codes[lightslategrey]=103
|
||||
codes[mediumpurple]=104
|
||||
codes[lightslateblue]=105
|
||||
codes[yellow4]=106
|
||||
codes[darkolivegreen3]=107
|
||||
codes[darkseagreen]=108
|
||||
codes[lightskyblue3]=109
|
||||
codes[lightskyblue3]=110
|
||||
codes[skyblue2]=111
|
||||
codes[chartreuse2]=112
|
||||
codes[darkolivegreen3]=113
|
||||
codes[palegreen3]=114
|
||||
codes[darkseagreen3]=115
|
||||
codes[darkslategray3]=116
|
||||
codes[skyblue1]=117
|
||||
codes[chartreuse1]=118
|
||||
codes[lightgreen]=119
|
||||
codes[lightgreen]=120
|
||||
codes[palegreen1]=121
|
||||
codes[aquamarine1]=122
|
||||
codes[darkslategray1]=123
|
||||
codes[red3]=124
|
||||
codes[deeppink4]=125
|
||||
codes[mediumvioletred]=126
|
||||
codes[magenta3]=127
|
||||
codes[darkviolet]=128
|
||||
codes[purple]=129
|
||||
codes[darkorange3]=130
|
||||
codes[indianred]=131
|
||||
codes[hotpink3]=132
|
||||
codes[mediumorchid3]=133
|
||||
codes[mediumorchid]=134
|
||||
codes[mediumpurple2]=135
|
||||
codes[darkgoldenrod]=136
|
||||
codes[lightsalmon3]=137
|
||||
codes[rosybrown]=138
|
||||
codes[grey63]=139
|
||||
codes[mediumpurple2]=140
|
||||
codes[mediumpurple1]=141
|
||||
codes[gold3]=142
|
||||
codes[darkkhaki]=143
|
||||
codes[navajowhite3]=144
|
||||
codes[grey69]=145
|
||||
codes[lightsteelblue3]=146
|
||||
codes[lightsteelblue]=147
|
||||
codes[yellow3]=148
|
||||
codes[darkolivegreen3]=149
|
||||
codes[darkseagreen3]=150
|
||||
codes[darkseagreen2]=151
|
||||
codes[lightcyan3]=152
|
||||
codes[lightskyblue1]=153
|
||||
codes[greenyellow]=154
|
||||
codes[darkolivegreen2]=155
|
||||
codes[palegreen1]=156
|
||||
codes[darkseagreen2]=157
|
||||
codes[darkseagreen1]=158
|
||||
codes[paleturquoise1]=159
|
||||
codes[red3]=160
|
||||
codes[deeppink3]=161
|
||||
codes[deeppink3]=162
|
||||
codes[magenta3]=163
|
||||
codes[magenta3]=164
|
||||
codes[magenta2]=165
|
||||
codes[darkorange3]=166
|
||||
codes[indianred]=167
|
||||
codes[hotpink3]=168
|
||||
codes[hotpink2]=169
|
||||
codes[orchid]=170
|
||||
codes[mediumorchid1]=171
|
||||
codes[orange3]=172
|
||||
codes[lightsalmon3]=173
|
||||
codes[lightpink3]=174
|
||||
codes[pink3]=175
|
||||
codes[plum3]=176
|
||||
codes[violet]=177
|
||||
codes[gold3]=178
|
||||
codes[lightgoldenrod3]=179
|
||||
codes[tan]=180
|
||||
codes[mistyrose3]=181
|
||||
codes[thistle3]=182
|
||||
codes[plum2]=183
|
||||
codes[yellow3]=184
|
||||
codes[khaki3]=185
|
||||
codes[lightgoldenrod2]=186
|
||||
codes[lightyellow3]=187
|
||||
codes[grey84]=188
|
||||
codes[lightsteelblue1]=189
|
||||
codes[yellow2]=190
|
||||
codes[darkolivegreen1]=191
|
||||
codes[darkolivegreen1]=192
|
||||
codes[darkseagreen1]=193
|
||||
codes[honeydew2]=194
|
||||
codes[lightcyan1]=195
|
||||
codes[red1]=196
|
||||
codes[deeppink2]=197
|
||||
codes[deeppink1]=198
|
||||
codes[deeppink1]=199
|
||||
codes[magenta2]=200
|
||||
codes[magenta1]=201
|
||||
codes[orangered1]=202
|
||||
codes[indianred1]=203
|
||||
codes[indianred1]=204
|
||||
codes[hotpink]=205
|
||||
codes[hotpink]=206
|
||||
codes[mediumorchid1]=207
|
||||
codes[darkorange]=208
|
||||
codes[salmon1]=209
|
||||
codes[lightcoral]=210
|
||||
codes[palevioletred1]=211
|
||||
codes[orchid2]=212
|
||||
codes[orchid1]=213
|
||||
codes[orange1]=214
|
||||
codes[sandybrown]=215
|
||||
codes[lightsalmon1]=216
|
||||
codes[lightpink1]=217
|
||||
codes[pink1]=218
|
||||
codes[plum1]=219
|
||||
codes[gold1]=220
|
||||
codes[lightgoldenrod2]=221
|
||||
codes[lightgoldenrod2]=222
|
||||
codes[navajowhite1]=223
|
||||
codes[mistyrose1]=224
|
||||
codes[thistle1]=225
|
||||
codes[yellow1]=226
|
||||
codes[lightgoldenrod1]=227
|
||||
codes[khaki1]=228
|
||||
codes[wheat1]=229
|
||||
codes[cornsilk1]=230
|
||||
codes[grey100]=231
|
||||
codes[grey3]=232
|
||||
codes[grey7]=233
|
||||
codes[grey11]=234
|
||||
codes[grey15]=235
|
||||
codes[grey19]=236
|
||||
codes[grey23]=237
|
||||
codes[grey27]=238
|
||||
codes[grey30]=239
|
||||
codes[grey35]=240
|
||||
codes[grey39]=241
|
||||
codes[grey42]=242
|
||||
codes[grey46]=243
|
||||
codes[grey50]=244
|
||||
codes[grey54]=245
|
||||
codes[grey58]=246
|
||||
codes[grey62]=247
|
||||
codes[grey66]=248
|
||||
codes[grey70]=249
|
||||
codes[grey74]=250
|
||||
codes[grey78]=251
|
||||
codes[grey82]=252
|
||||
codes[grey85]=253
|
||||
codes[grey89]=254
|
||||
codes[grey93]=255
|
||||
# Early exit: Check if given value is already numerical
|
||||
if [[ "$1" == <-> ]]; then
|
||||
# Pad color with zeroes
|
||||
echo -n "${(l:3::0:)1}"
|
||||
return
|
||||
fi
|
||||
|
||||
# for testing purposes in terminal
|
||||
if [[ "$1" == "foreground" ]]; then
|
||||
# call via `getColorCode foreground`
|
||||
for i in "${(k@)codes}"; do
|
||||
print -P "$(foregroundColor $i)$(getColor $i) - $i$(foregroundColor)"
|
||||
done
|
||||
elif [[ "$1" == "background" ]]; then
|
||||
# call via `getColorCode background`
|
||||
for i in "${(k@)codes}"; do
|
||||
print -P "$(backgroundColor $i)$(getColor $i) - $i$(backgroundColor)"
|
||||
done
|
||||
else
|
||||
#[[ -n "$1" ]] bg="%K{$1}" || bg="%k"
|
||||
# Strip eventual "bg-" prefixes
|
||||
1=${1#bg-}
|
||||
# Strip eventual "fg-" prefixes
|
||||
1=${1#fg-}
|
||||
# Strip eventual "br" prefixes ("bright" colors)
|
||||
1=${1#br}
|
||||
echo -n $codes[$1]
|
||||
fi
|
||||
local colorName="${1}"
|
||||
# Check if value is none with any case.
|
||||
if [[ "${(L)colorName}" == "none" ]]; then
|
||||
echo -n 'none'
|
||||
elif [[ "${colorName}" == "foreground" ]]; then
|
||||
# for testing purposes in terminal
|
||||
# call via `getColorCode foreground`
|
||||
for i in "${(k@)__P9K_COLORS}"; do
|
||||
print -P "$(foregroundColor $i)$(getColor $i) - $i%f"
|
||||
done
|
||||
elif [[ "${colorName}" == "background" ]]; then
|
||||
# call via `getColorCode background`
|
||||
for i in "${(k@)__P9K_COLORS}"; do
|
||||
print -P "$(backgroundColor $i)$(getColor $i) - $i%k"
|
||||
done
|
||||
else
|
||||
# Strip eventual "bg-" prefixes
|
||||
colorName=${colorName#bg-}
|
||||
# Strip eventual "fg-" prefixes
|
||||
colorName=${colorName#fg-}
|
||||
# Strip eventual "br" prefixes ("bright" colors)
|
||||
colorName=${colorName#br}
|
||||
echo -n $__P9K_COLORS[$colorName]
|
||||
fi
|
||||
}
|
||||
|
||||
|
@@ -48,24 +48,24 @@ case $POWERLEVEL9K_MODE in
|
||||
FREEBSD_ICON $'\U1F608 ' # 😈
|
||||
ANDROID_ICON $'\uE270' #
|
||||
LINUX_ICON $'\uE271' #
|
||||
LINUX_ARCH_ICON 'Arc'
|
||||
LINUX_DEBIAN_ICON 'Deb'
|
||||
LINUX_UBUNTU_ICON 'Ubu'
|
||||
LINUX_CENTOS_ICON 'Cen'
|
||||
LINUX_COREOS_ICON 'Cor'
|
||||
LINUX_ELEMENTARY_ICON 'Elm'
|
||||
LINUX_MINT_ICON 'LMi'
|
||||
LINUX_FEDORA_ICON 'Fed'
|
||||
LINUX_GENTOO_ICON 'Gen'
|
||||
LINUX_MAGEIA_ICON 'Mag'
|
||||
LINUX_NIXOS_ICON 'Nix'
|
||||
LINUX_MANJARO_ICON 'Man'
|
||||
LINUX_DEVUAN_ICON 'Dev'
|
||||
LINUX_ALPINE_ICON 'Alp'
|
||||
LINUX_AOSC_ICON 'Aos'
|
||||
LINUX_OPENSUSE_ICON 'OSu'
|
||||
LINUX_SABAYON_ICON 'Sab'
|
||||
LINUX_SLACKWARE_ICON 'Sla'
|
||||
LINUX_ARCH_ICON $'\uE271' #
|
||||
LINUX_DEBIAN_ICON $'\uE271' #
|
||||
LINUX_UBUNTU_ICON $'\uE271' #
|
||||
LINUX_CENTOS_ICON $'\uE271' #
|
||||
LINUX_COREOS_ICON $'\uE271' #
|
||||
LINUX_ELEMENTARY_ICON $'\uE271' #
|
||||
LINUX_MINT_ICON $'\uE271' #
|
||||
LINUX_FEDORA_ICON $'\uE271' #
|
||||
LINUX_GENTOO_ICON $'\uE271' #
|
||||
LINUX_MAGEIA_ICON $'\uE271' #
|
||||
LINUX_NIXOS_ICON $'\uE271' #
|
||||
LINUX_MANJARO_ICON $'\uE271' #
|
||||
LINUX_DEVUAN_ICON $'\uE271' #
|
||||
LINUX_ALPINE_ICON $'\uE271' #
|
||||
LINUX_AOSC_ICON $'\uE271' #
|
||||
LINUX_OPENSUSE_ICON $'\uE271' #
|
||||
LINUX_SABAYON_ICON $'\uE271' #
|
||||
LINUX_SLACKWARE_ICON $'\uE271' #
|
||||
SUNOS_ICON $'\U1F31E ' # 🌞
|
||||
HOME_ICON $'\uE12C' #
|
||||
HOME_SUB_ICON $'\uE18D' #
|
||||
@@ -148,24 +148,24 @@ case $POWERLEVEL9K_MODE in
|
||||
FREEBSD_ICON $'\U1F608 ' # 😈
|
||||
ANDROID_ICON $'\uE17B' #
|
||||
LINUX_ICON $'\uF17C' #
|
||||
LINUX_ARCH_ICON 'Arc'
|
||||
LINUX_DEBIAN_ICON 'Deb'
|
||||
LINUX_UBUNTU_ICON 'Ubu'
|
||||
LINUX_CENTOS_ICON 'Cen'
|
||||
LINUX_COREOS_ICON 'Cor'
|
||||
LINUX_ELEMENTARY_ICON 'Elm'
|
||||
LINUX_MINT_ICON 'LMi'
|
||||
LINUX_FEDORA_ICON 'Fed'
|
||||
LINUX_GENTOO_ICON 'Gen'
|
||||
LINUX_MAGEIA_ICON 'Mag'
|
||||
LINUX_NIXOS_ICON 'Nix'
|
||||
LINUX_MANJARO_ICON 'Man'
|
||||
LINUX_DEVUAN_ICON 'Dev'
|
||||
LINUX_ALPINE_ICON 'Alp'
|
||||
LINUX_AOSC_ICON 'Aos'
|
||||
LINUX_OPENSUSE_ICON 'OSu'
|
||||
LINUX_SABAYON_ICON 'Sab'
|
||||
LINUX_SLACKWARE_ICON 'Sla'
|
||||
LINUX_ARCH_ICON $'\uF17C' #
|
||||
LINUX_DEBIAN_ICON $'\uF17C' #
|
||||
LINUX_UBUNTU_ICON $'\uF17C' #
|
||||
LINUX_CENTOS_ICON $'\uF17C' #
|
||||
LINUX_COREOS_ICON $'\uF17C' #
|
||||
LINUX_ELEMENTARY_ICON $'\uF17C' #
|
||||
LINUX_MINT_ICON $'\uF17C' #
|
||||
LINUX_FEDORA_ICON $'\uF17C' #
|
||||
LINUX_GENTOO_ICON $'\uF17C' #
|
||||
LINUX_MAGEIA_ICON $'\uF17C' #
|
||||
LINUX_NIXOS_ICON $'\uF17C' #
|
||||
LINUX_MANJARO_ICON $'\uF17C' #
|
||||
LINUX_DEVUAN_ICON $'\uF17C' #
|
||||
LINUX_ALPINE_ICON $'\uF17C' #
|
||||
LINUX_AOSC_ICON $'\uF17C' #
|
||||
LINUX_OPENSUSE_ICON $'\uF17C' #
|
||||
LINUX_SABAYON_ICON $'\uF17C' #
|
||||
LINUX_SLACKWARE_ICON $'\uF17C' #
|
||||
SUNOS_ICON $'\uF185 ' #
|
||||
HOME_ICON $'\uF015' #
|
||||
HOME_SUB_ICON $'\uF07C' #
|
||||
@@ -250,24 +250,24 @@ case $POWERLEVEL9K_MODE in
|
||||
APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE #
|
||||
FREEBSD_ICON $'\U1F608 ' # 😈
|
||||
LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_ARCH_ICON 'Arc'
|
||||
LINUX_DEBIAN_ICON 'Deb'
|
||||
LINUX_UBUNTU_ICON 'Ubu'
|
||||
LINUX_CENTOS_ICON 'Cen'
|
||||
LINUX_COREOS_ICON 'Cor'
|
||||
LINUX_ELEMENTARY_ICON 'Elm'
|
||||
LINUX_MINT_ICON 'LMi'
|
||||
LINUX_FEDORA_ICON 'Fed'
|
||||
LINUX_GENTOO_ICON 'Gen'
|
||||
LINUX_MAGEIA_ICON 'Mag'
|
||||
LINUX_NIXOS_ICON 'Nix'
|
||||
LINUX_MANJARO_ICON 'Man'
|
||||
LINUX_DEVUAN_ICON 'Dev'
|
||||
LINUX_ALPINE_ICON 'Alp'
|
||||
LINUX_AOSC_ICON 'Aos'
|
||||
LINUX_OPENSUSE_ICON 'OSu'
|
||||
LINUX_SABAYON_ICON 'Sab'
|
||||
LINUX_SLACKWARE_ICON 'Sla'
|
||||
LINUX_ARCH_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_DEBIAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_UBUNTU_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_CENTOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_COREOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_ELEMENTARY_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_MINT_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_FEDORA_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_GENTOO_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_MAGEIA_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_NIXOS_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_MANJARO_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_DEVUAN_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_ALPINE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_AOSC_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_OPENSUSE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_SABAYON_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
LINUX_SLACKWARE_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX #
|
||||
SUNOS_ICON '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' #
|
||||
HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME #
|
||||
HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN #
|
||||
|
@@ -9,9 +9,7 @@
|
||||
# Exits with 0 if a variable has been previously defined (even if empty)
|
||||
# Takes the name of a variable that should be checked.
|
||||
function defined() {
|
||||
local varname="$1"
|
||||
|
||||
typeset -p "$varname" > /dev/null 2>&1
|
||||
[[ ! -z "${(tP)1}" ]]
|
||||
}
|
||||
|
||||
# Given the name of a variable and a default value, sets the variable
|
||||
|
@@ -111,45 +111,54 @@ CURRENT_BG='NONE'
|
||||
set_default last_left_element_index 1
|
||||
set_default POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS " "
|
||||
left_prompt_segment() {
|
||||
local segment_name="${1}"
|
||||
local current_index=$2
|
||||
# Check if the segment should be joined with the previous one
|
||||
local joined
|
||||
segmentShouldBeJoined $current_index $last_left_element_index "$POWERLEVEL9K_LEFT_PROMPT_ELEMENTS" && joined=true || joined=false
|
||||
|
||||
# Colors
|
||||
local backgroundColor="${3}"
|
||||
local foregroundColor="${4}"
|
||||
|
||||
# Overwrite given background-color by user defined variable for this segment.
|
||||
local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_BACKGROUND
|
||||
local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)${segment_name}#prompt_}_BACKGROUND
|
||||
local BG_COLOR_MODIFIER=${(P)BACKGROUND_USER_VARIABLE}
|
||||
[[ -n $BG_COLOR_MODIFIER ]] && 3="$BG_COLOR_MODIFIER"
|
||||
[[ -n $BG_COLOR_MODIFIER ]] && backgroundColor="$BG_COLOR_MODIFIER"
|
||||
|
||||
# Overwrite given foreground-color by user defined variable for this segment.
|
||||
local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_FOREGROUND
|
||||
local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)${segment_name}#prompt_}_FOREGROUND
|
||||
local FG_COLOR_MODIFIER=${(P)FOREGROUND_USER_VARIABLE}
|
||||
[[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER"
|
||||
[[ -n $FG_COLOR_MODIFIER ]] && foregroundColor="$FG_COLOR_MODIFIER"
|
||||
|
||||
local bg fg
|
||||
[[ -n "$3" ]] && bg="$(backgroundColor $3)" || bg="$(backgroundColor)"
|
||||
[[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)"
|
||||
# Get color codes here to save some calls later on
|
||||
backgroundColor="$(getColorCode ${backgroundColor})"
|
||||
foregroundColor="$(getColorCode ${foregroundColor})"
|
||||
|
||||
if [[ $CURRENT_BG != 'NONE' ]] && ! isSameColor "$3" "$CURRENT_BG"; then
|
||||
echo -n "$bg%F{$CURRENT_BG}"
|
||||
local background foreground
|
||||
[[ -n "${backgroundColor}" ]] && background="$(backgroundColor ${backgroundColor})" || background="%k"
|
||||
[[ -n "${foregroundColor}" ]] && foreground="$(foregroundColor ${foregroundColor})" || foreground="%f"
|
||||
|
||||
if [[ $CURRENT_BG != 'NONE' ]] && ! isSameColor "${backgroundColor}" "$CURRENT_BG"; then
|
||||
echo -n "${background}%F{$CURRENT_BG}"
|
||||
if [[ $joined == false ]]; then
|
||||
# Middle segment
|
||||
echo -n "$(print_icon 'LEFT_SEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS"
|
||||
fi
|
||||
elif isSameColor "$CURRENT_BG" "$3"; then
|
||||
elif isSameColor "$CURRENT_BG" "${backgroundColor}"; then
|
||||
# Middle segment with same color as previous segment
|
||||
# We take the current foreground color as color for our
|
||||
# subsegment (or the default color). This should have
|
||||
# enough contrast.
|
||||
local complement
|
||||
[[ -n "$4" ]] && complement="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)"
|
||||
echo -n "${bg}${complement}"
|
||||
[[ -n "${foregroundColor}" ]] && complement="${foreground}" || complement="$(foregroundColor $DEFAULT_COLOR)"
|
||||
echo -n "${background}${complement}"
|
||||
if [[ $joined == false ]]; then
|
||||
echo -n "$(print_icon 'LEFT_SUBSEGMENT_SEPARATOR')$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS"
|
||||
fi
|
||||
else
|
||||
# First segment
|
||||
echo -n "${bg}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS"
|
||||
echo -n "${background}$POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS"
|
||||
fi
|
||||
|
||||
local visual_identifier
|
||||
@@ -161,26 +170,26 @@ left_prompt_segment() {
|
||||
# we need to color both the visual identifier and the whitespace.
|
||||
[[ -n "$5" ]] && visual_identifier="$visual_identifier "
|
||||
# Allow users to overwrite the color for the visual identifier only.
|
||||
local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR
|
||||
set_default $visual_identifier_color_variable $4
|
||||
visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f"
|
||||
local visual_identifier_color_variable=POWERLEVEL9K_${(U)${segment_name}#prompt_}_VISUAL_IDENTIFIER_COLOR
|
||||
set_default $visual_identifier_color_variable "${foregroundColor}"
|
||||
visual_identifier="$(foregroundColor ${(P)visual_identifier_color_variable})${visual_identifier}%f"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Print the visual identifier
|
||||
echo -n "${visual_identifier}"
|
||||
# Print the content of the segment, if there is any
|
||||
[[ -n "$5" ]] && echo -n "${fg}${5}"
|
||||
[[ -n "$5" ]] && echo -n "${foreground}${5}"
|
||||
echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_LEFT_SEGMENTS}"
|
||||
|
||||
CURRENT_BG=$3
|
||||
CURRENT_BG="${backgroundColor}"
|
||||
last_left_element_index=$current_index
|
||||
}
|
||||
|
||||
# End the left prompt, closes the final segment.
|
||||
left_prompt_end() {
|
||||
if [[ -n $CURRENT_BG ]]; then
|
||||
echo -n "%k%F{$CURRENT_BG}$(print_icon 'LEFT_SEGMENT_SEPARATOR')"
|
||||
echo -n "%k$(foregroundColor ${CURRENT_BG})$(print_icon 'LEFT_SEGMENT_SEPARATOR')"
|
||||
else
|
||||
echo -n "%k"
|
||||
fi
|
||||
@@ -203,25 +212,34 @@ CURRENT_RIGHT_BG='NONE'
|
||||
set_default last_right_element_index 1
|
||||
set_default POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS " "
|
||||
right_prompt_segment() {
|
||||
local segment_name="${1}"
|
||||
local current_index=$2
|
||||
|
||||
# Check if the segment should be joined with the previous one
|
||||
local joined
|
||||
segmentShouldBeJoined $current_index $last_right_element_index "$POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS" && joined=true || joined=false
|
||||
|
||||
# Colors
|
||||
local backgroundColor="${3}"
|
||||
local foregroundColor="${4}"
|
||||
|
||||
# Overwrite given background-color by user defined variable for this segment.
|
||||
local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_BACKGROUND
|
||||
local BACKGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)${segment_name}#prompt_}_BACKGROUND
|
||||
local BG_COLOR_MODIFIER=${(P)BACKGROUND_USER_VARIABLE}
|
||||
[[ -n $BG_COLOR_MODIFIER ]] && 3="$BG_COLOR_MODIFIER"
|
||||
[[ -n $BG_COLOR_MODIFIER ]] && backgroundColor="$BG_COLOR_MODIFIER"
|
||||
|
||||
# Overwrite given foreground-color by user defined variable for this segment.
|
||||
local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)1#prompt_}_FOREGROUND
|
||||
local FOREGROUND_USER_VARIABLE=POWERLEVEL9K_${(U)${segment_name}#prompt_}_FOREGROUND
|
||||
local FG_COLOR_MODIFIER=${(P)FOREGROUND_USER_VARIABLE}
|
||||
[[ -n $FG_COLOR_MODIFIER ]] && 4="$FG_COLOR_MODIFIER"
|
||||
[[ -n $FG_COLOR_MODIFIER ]] && foregroundColor="$FG_COLOR_MODIFIER"
|
||||
|
||||
local bg fg
|
||||
[[ -n "$3" ]] && bg="$(backgroundColor $3)" || bg="$(backgroundColor)"
|
||||
[[ -n "$4" ]] && fg="$(foregroundColor $4)" || fg="$(foregroundColor)"
|
||||
# Get color codes here to save some calls later on
|
||||
backgroundColor="$(getColorCode ${backgroundColor})"
|
||||
foregroundColor="$(getColorCode ${foregroundColor})"
|
||||
|
||||
local background foreground
|
||||
[[ -n "${backgroundColor}" ]] && background="$(backgroundColor ${backgroundColor})" || background="%k"
|
||||
[[ -n "${foregroundColor}" ]] && foreground="$(foregroundColor ${foregroundColor})" || foreground="%f"
|
||||
|
||||
# If CURRENT_RIGHT_BG is "NONE", we are the first right segment.
|
||||
|
||||
@@ -231,17 +249,17 @@ right_prompt_segment() {
|
||||
fi
|
||||
|
||||
if [[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]]; then
|
||||
if isSameColor "$CURRENT_RIGHT_BG" "$3"; then
|
||||
if isSameColor "$CURRENT_RIGHT_BG" "${backgroundColor}"; then
|
||||
# Middle segment with same color as previous segment
|
||||
# We take the current foreground color as color for our
|
||||
# subsegment (or the default color). This should have
|
||||
# enough contrast.
|
||||
local complement
|
||||
[[ -n "$4" ]] && complement="$fg" || complement="$(foregroundColor $DEFAULT_COLOR)"
|
||||
[[ -n "${foregroundColor}" ]] && complement="${foreground}" || complement="$(foregroundColor $DEFAULT_COLOR)"
|
||||
echo -n "$complement$(print_icon 'RIGHT_SUBSEGMENT_SEPARATOR')%f"
|
||||
else
|
||||
# Use the new BG color for the foreground with separator
|
||||
echo -n "$(foregroundColor $3)$(print_icon 'RIGHT_SEGMENT_SEPARATOR')%f"
|
||||
# Use the new Background Color as the foreground of the segment separator
|
||||
echo -n "$(foregroundColor ${backgroundColor})$(print_icon 'RIGHT_SEGMENT_SEPARATOR')%f"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -254,13 +272,13 @@ right_prompt_segment() {
|
||||
# we need to color both the visual identifier and the whitespace.
|
||||
[[ -n "$5" ]] && visual_identifier=" $visual_identifier"
|
||||
# Allow users to overwrite the color for the visual identifier only.
|
||||
local visual_identifier_color_variable=POWERLEVEL9K_${(U)1#prompt_}_VISUAL_IDENTIFIER_COLOR
|
||||
set_default $visual_identifier_color_variable $4
|
||||
visual_identifier="%F{${(P)visual_identifier_color_variable}%}$visual_identifier%f"
|
||||
local visual_identifier_color_variable=POWERLEVEL9K_${(U)${segment_name}#prompt_}_VISUAL_IDENTIFIER_COLOR
|
||||
set_default $visual_identifier_color_variable "${foregroundColor}"
|
||||
visual_identifier="$(foregroundColor ${(P)visual_identifier_color_variable})${visual_identifier}%f"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -n "${bg}${fg}"
|
||||
echo -n "${background}${foreground}"
|
||||
|
||||
# Print whitespace only if segment is not joined or first right segment
|
||||
[[ $joined == false ]] || [[ "$CURRENT_RIGHT_BG" == "NONE" ]] && echo -n "${POWERLEVEL9K_WHITESPACE_BETWEEN_RIGHT_SEGMENTS}"
|
||||
@@ -270,7 +288,7 @@ right_prompt_segment() {
|
||||
# Print the visual identifier
|
||||
echo -n "${visual_identifier}"
|
||||
|
||||
CURRENT_RIGHT_BG=$3
|
||||
CURRENT_RIGHT_BG="${backgroundColor}"
|
||||
last_right_element_index=$current_index
|
||||
}
|
||||
|
||||
@@ -278,11 +296,6 @@ right_prompt_segment() {
|
||||
# Prompt Segment Definitions
|
||||
################################################################
|
||||
|
||||
# The `CURRENT_BG` variable is used to remember what the last BG color used was
|
||||
# when building the left-hand prompt. Because the RPROMPT is created from
|
||||
# right-left but reads the opposite, this isn't necessary for the other side.
|
||||
CURRENT_BG='NONE'
|
||||
|
||||
################################################################
|
||||
# Anaconda Environment
|
||||
prompt_anaconda() {
|
||||
@@ -409,12 +422,13 @@ prompt_battery() {
|
||||
'charged' 'green'
|
||||
'disconnected' "$DEFAULT_COLOR_INVERTED"
|
||||
)
|
||||
local ROOT_PREFIX="${4}"
|
||||
# Set default values if the user did not configure them
|
||||
set_default POWERLEVEL9K_BATTERY_LOW_THRESHOLD 10
|
||||
|
||||
if [[ $OS =~ OSX && -f /usr/bin/pmset && -x /usr/bin/pmset ]]; then
|
||||
if [[ $OS =~ OSX && -f "${ROOT_PREFIX}"/usr/bin/pmset && -x "${ROOT_PREFIX}"/usr/bin/pmset ]]; then
|
||||
# obtain battery information from system
|
||||
local raw_data="$(pmset -g batt | awk 'FNR==2{print}')"
|
||||
local raw_data="$(${ROOT_PREFIX}/usr/bin/pmset -g batt | awk 'FNR==2{print}')"
|
||||
# return if there is no battery on system
|
||||
[[ -z $(echo $raw_data | grep "InternalBattery") ]] && return
|
||||
|
||||
@@ -446,7 +460,7 @@ prompt_battery() {
|
||||
fi
|
||||
|
||||
if [[ "$OS" == 'Linux' ]] || [[ "$OS" == 'Android' ]]; then
|
||||
local sysp="/sys/class/power_supply"
|
||||
local sysp="${ROOT_PREFIX}/sys/class/power_supply"
|
||||
|
||||
# Reported BAT0 or BAT1 depending on kernel version
|
||||
[[ -a $sysp/BAT0 ]] && local bat=$sysp/BAT0
|
||||
@@ -468,8 +482,8 @@ prompt_battery() {
|
||||
[[ $bat_percent =~ 100 ]] && current_state="charged"
|
||||
[[ $bat_percent -lt 100 ]] && current_state="charging"
|
||||
fi
|
||||
if [[ -f /usr/bin/acpi ]]; then
|
||||
local time_remaining=$(acpi | awk '{ print $5 }')
|
||||
if [[ -f ${ROOT_PREFIX}/usr/bin/acpi ]]; then
|
||||
local time_remaining=$(${ROOT_PREFIX}/usr/bin/acpi | awk '{ print $5 }')
|
||||
if [[ $time_remaining =~ rate ]]; then
|
||||
local tstring="..."
|
||||
elif [[ $time_remaining =~ "[[:digit:]]+" ]]; then
|
||||
@@ -498,7 +512,7 @@ prompt_battery() {
|
||||
fi
|
||||
fi
|
||||
# return if POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD is set and the battery percentage is greater or equal
|
||||
if [[ -v "POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD" && "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then
|
||||
if defined POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD && [[ "${bat_percent}" -ge $POWERLEVEL9K_BATTERY_HIDE_ABOVE_THRESHOLD ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -623,12 +637,12 @@ prompt_context() {
|
||||
if [[ $(print -P "%#") == '#' ]]; then
|
||||
current_state="ROOT"
|
||||
elif [[ -n "$SSH_CLIENT" || -n "$SSH_TTY" ]]; then
|
||||
if sudo -n true 2>/dev/null; then
|
||||
if [[ -n "$SUDO_COMMAND" ]]; then
|
||||
current_state="REMOTE_SUDO"
|
||||
else
|
||||
current_state="REMOTE"
|
||||
fi
|
||||
elif sudo -n true 2>/dev/null; then
|
||||
elif [[ -n "$SUDO_COMMAND" ]]; then
|
||||
current_state="SUDO"
|
||||
fi
|
||||
|
||||
@@ -651,7 +665,7 @@ prompt_user() {
|
||||
"FOREGROUND_COLOR" "yellow"
|
||||
"VISUAL_IDENTIFIER" "ROOT_ICON"
|
||||
)
|
||||
elif sudo -n true 2>/dev/null; then
|
||||
elif [[ -n "$SUDO_COMMAND" ]]; then
|
||||
user_state=(
|
||||
"STATE" "SUDO"
|
||||
"CONTENT" "${POWERLEVEL9K_USER_TEMPLATE}"
|
||||
@@ -702,11 +716,13 @@ prompt_host() {
|
||||
# The 'custom` prompt provides a way for users to invoke commands and display
|
||||
# the output in a segment.
|
||||
prompt_custom() {
|
||||
local command=POWERLEVEL9K_CUSTOM_$3:u
|
||||
local segment_name="${3:u}"
|
||||
# Get content of custom segment
|
||||
local command="POWERLEVEL9K_CUSTOM_${segment_name}"
|
||||
local segment_content="$(eval ${(P)command})"
|
||||
|
||||
if [[ -n $segment_content ]]; then
|
||||
"$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content"
|
||||
"$1_prompt_segment" "${0}_${3:u}" "$2" $DEFAULT_COLOR_INVERTED $DEFAULT_COLOR "$segment_content" "CUSTOM_${segment_name}_ICON"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -744,6 +760,31 @@ prompt_command_execution_time() {
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################
|
||||
# Determine the unique path - this is needed for the
|
||||
# truncate_to_unique strategy.
|
||||
#
|
||||
function getUniqueFolder() {
|
||||
local trunc_path directory test_dir test_dir_length
|
||||
local -a matching
|
||||
local -a paths
|
||||
local cur_path='/'
|
||||
paths=(${(s:/:)1})
|
||||
for directory in ${paths[@]}; do
|
||||
test_dir=''
|
||||
for (( i=0; i < ${#directory}; i++ )); do
|
||||
test_dir+="${directory:$i:1}"
|
||||
matching=("$cur_path"/"$test_dir"*/)
|
||||
if [[ ${#matching[@]} -eq 1 ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
trunc_path+="$test_dir/"
|
||||
cur_path+="$directory/"
|
||||
done
|
||||
echo "${trunc_path: : -1}"
|
||||
}
|
||||
|
||||
################################################################
|
||||
# Dir: current working directory
|
||||
# Parameters:
|
||||
@@ -811,23 +852,10 @@ prompt_dir() {
|
||||
# for each parent path component find the shortest unique beginning
|
||||
# characters sequence. Source: https://stackoverflow.com/a/45336078
|
||||
if (( ${#current_path} > 1 )); then # root and home are exceptions and won't have paths
|
||||
local matching
|
||||
local cur_path='/'
|
||||
[[ $current_path != "~"* ]] && trunc_path='/' || trunc_path=''
|
||||
for directory in ${paths[@]}; do
|
||||
test_dir=''
|
||||
for (( i=0; i<${#directory}; i++ )); do
|
||||
test_dir+="${directory:$i:1}"
|
||||
matching=("$cur_path"/"$test_dir"*/)
|
||||
if [[ ${#matching[@]} -eq 1 ]]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
trunc_path+="$test_dir/"
|
||||
cur_path+="$directory/"
|
||||
done
|
||||
[[ $current_path == "~"* ]] && trunc_path="~/$trunc_path"
|
||||
current_path="${trunc_path: : -1}"
|
||||
# cheating here to retain ~ as home folder
|
||||
local home_path="$(getUniqueFolder $HOME)"
|
||||
trunc_path="$(getUniqueFolder $PWD)"
|
||||
[[ $current_path == "~"* ]] && current_path="~${trunc_path//${home_path}/}" || current_path="/${trunc_path}"
|
||||
fi
|
||||
;;
|
||||
truncate_with_folder_marker)
|
||||
@@ -1043,18 +1071,14 @@ prompt_history() {
|
||||
################################################################
|
||||
# Detection for virtualization (systemd based systems only)
|
||||
prompt_detect_virt() {
|
||||
if ! command -v systemd-detect-virt > /dev/null; then
|
||||
return
|
||||
fi
|
||||
local virt=$(systemd-detect-virt)
|
||||
local virt=$(systemd-detect-virt 2> /dev/null)
|
||||
if [[ "$virt" == "none" ]]; then
|
||||
if [[ "$(ls -di / | grep -o 2)" != "2" ]]; then
|
||||
virt="chroot"
|
||||
"$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt"
|
||||
else
|
||||
;
|
||||
fi
|
||||
else
|
||||
fi
|
||||
|
||||
if [[ -n "${virt}" ]]; then
|
||||
"$1_prompt_segment" "$0" "$2" "$DEFAULT_COLOR" "yellow" "$virt"
|
||||
fi
|
||||
}
|
||||
@@ -1089,18 +1113,20 @@ prompt_ip() {
|
||||
else
|
||||
if defined POWERLEVEL9K_IP_INTERFACE; then
|
||||
# Get the IP address of the specified interface.
|
||||
ip=$(ip -4 a show "$POWERLEVEL9K_IP_INTERFACE" | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*")
|
||||
ip=$(ip -4 a show "$POWERLEVEL9K_IP_INTERFACE" | grep -o "inet\s*[0-9.]*" | grep -o -E "[0-9.]+")
|
||||
else
|
||||
local interfaces callback
|
||||
# Get all network interface names that are up
|
||||
interfaces=$(ip link ls up | grep -o -E ":\s+[a-z0-9]+:" | grep -v "lo" | grep -o "[a-z0-9]*")
|
||||
callback='ip -4 a show $item | grep -o "inet\s*[0-9.]*" | grep -o "[0-9.]*"'
|
||||
interfaces=$(ip link ls up | grep -o -E ":\s+[a-z0-9]+:" | grep -v "lo" | grep -o -E "[a-z0-9]+")
|
||||
callback='ip -4 a show $item | grep -o "inet\s*[0-9.]*" | grep -o -E "[0-9.]+"'
|
||||
|
||||
ip=$(getRelevantItem "$interfaces" "$callback")
|
||||
fi
|
||||
fi
|
||||
|
||||
"$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON'
|
||||
if [[ -n "$ip" ]]; then
|
||||
"$1_prompt_segment" "$0" "$2" "cyan" "$DEFAULT_COLOR" "$ip" 'NETWORK_ICON'
|
||||
fi
|
||||
}
|
||||
|
||||
################################################################
|
||||
@@ -1118,11 +1144,10 @@ prompt_vpn_ip() {
|
||||
################################################################
|
||||
# Segment to display laravel version
|
||||
prompt_laravel_version() {
|
||||
local laravel_version="$(php artisan --version 2>/dev/null)"
|
||||
if [[ -n "${laravel_version}" ]]; then
|
||||
# Remove unrelevant infos
|
||||
laravel_version="${laravel_version//Laravel Framework version /}"
|
||||
|
||||
local laravel_version="$(php artisan --version 2> /dev/null)"
|
||||
if [[ -n "${laravel_version}" && "${laravel_version}" =~ "Laravel Framework" ]]; then
|
||||
# Strip out everything but the version
|
||||
laravel_version="${laravel_version//Laravel Framework /}"
|
||||
"$1_prompt_segment" "$0" "$2" "maroon" "white" "${laravel_version}" 'LARAVEL_ICON'
|
||||
fi
|
||||
}
|
||||
@@ -1131,6 +1156,7 @@ prompt_laravel_version() {
|
||||
# Segment to display load
|
||||
set_default POWERLEVEL9K_LOAD_WHICH 5
|
||||
prompt_load() {
|
||||
local ROOT_PREFIX="${4}"
|
||||
# The load segment can have three different states
|
||||
local current_state="unknown"
|
||||
local load_select=2
|
||||
@@ -1166,7 +1192,7 @@ prompt_load() {
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
load_avg=$(cut -d" " -f${load_select} /proc/loadavg)
|
||||
load_avg=$(cut -d" " -f${load_select} ${ROOT_PREFIX}/proc/loadavg)
|
||||
cores=$(nproc)
|
||||
esac
|
||||
|
||||
@@ -1239,6 +1265,7 @@ prompt_php_version() {
|
||||
################################################################
|
||||
# Segment to display free RAM and used Swap
|
||||
prompt_ram() {
|
||||
local ROOT_PREFIX="${4}"
|
||||
local base=''
|
||||
local ramfree=0
|
||||
if [[ "$OS" == "OSX" ]]; then
|
||||
@@ -1250,9 +1277,9 @@ prompt_ram() {
|
||||
ramfree=$(( ramfree * 4096 ))
|
||||
else
|
||||
if [[ "$OS" == "BSD" ]]; then
|
||||
ramfree=$(grep 'avail memory' /var/run/dmesg.boot | awk '{print $4}')
|
||||
ramfree=$(grep 'avail memory' ${ROOT_PREFIX}/var/run/dmesg.boot | awk '{print $4}')
|
||||
else
|
||||
ramfree=$(grep -o -E "MemAvailable:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
||||
ramfree=$(grep -o -E "MemAvailable:\s+[0-9]+" ${ROOT_PREFIX}/proc/meminfo | grep -o -E "[0-9]+")
|
||||
base='K'
|
||||
fi
|
||||
fi
|
||||
@@ -1260,21 +1287,19 @@ prompt_ram() {
|
||||
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON'
|
||||
}
|
||||
|
||||
|
||||
################################################################
|
||||
# Segment to display rbenv information
|
||||
# https://github.com/rbenv/rbenv#choosing-the-ruby-version
|
||||
set_default POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW false
|
||||
# rbenv information
|
||||
prompt_rbenv() {
|
||||
if command which rbenv 2>/dev/null >&2; then
|
||||
if [[ -n "$RBENV_VERSION" ]]; then
|
||||
"$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$RBENV_VERSION" 'RUBY_ICON'
|
||||
elif [ $commands[rbenv] ]; then
|
||||
local rbenv_version_name="$(rbenv version-name)"
|
||||
local rbenv_global="$(rbenv global)"
|
||||
|
||||
# Don't show anything if the current Ruby is the same as the global Ruby
|
||||
# unless `POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW` is set.
|
||||
if [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then
|
||||
return
|
||||
if [[ "${rbenv_version_name}" != "${rbenv_global}" || "${POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW}" == "true" ]]; then
|
||||
"$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON'
|
||||
fi
|
||||
|
||||
"$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON'
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1419,6 +1444,7 @@ prompt_status() {
|
||||
################################################################
|
||||
# Segment to display Swap information
|
||||
prompt_swap() {
|
||||
local ROOT_PREFIX="${4}"
|
||||
local swap_used=0
|
||||
local base=''
|
||||
|
||||
@@ -1433,8 +1459,8 @@ prompt_swap() {
|
||||
|
||||
base=$(echo "$raw_swap_used" | grep -o "[A-Z]*$")
|
||||
else
|
||||
swap_total=$(grep -o -E "SwapTotal:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
||||
swap_free=$(grep -o -E "SwapFree:\s+[0-9]+" /proc/meminfo | grep -o "[0-9]*")
|
||||
swap_total=$(grep -o -E "SwapTotal:\s+[0-9]+" ${ROOT_PREFIX}/proc/meminfo | grep -o -E "[0-9]+")
|
||||
swap_free=$(grep -o -E "SwapFree:\s+[0-9]+" ${ROOT_PREFIX}/proc/meminfo | grep -o -E "[0-9]+")
|
||||
swap_used=$(( swap_total - swap_free ))
|
||||
base='K'
|
||||
fi
|
||||
@@ -1607,7 +1633,7 @@ set_default POWERLEVEL9K_VI_COMMAND_MODE_STRING "NORMAL"
|
||||
prompt_vi_mode() {
|
||||
case ${KEYMAP} in
|
||||
vicmd)
|
||||
"$1_prompt_segment" "$0_NORMAL" "$2" "$DEFAULT_COLOR" "default" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING"
|
||||
"$1_prompt_segment" "$0_NORMAL" "$2" "$DEFAULT_COLOR" "white" "$POWERLEVEL9K_VI_COMMAND_MODE_STRING"
|
||||
;;
|
||||
main|viins|*)
|
||||
if [[ -z $POWERLEVEL9K_VI_INSERT_MODE_STRING ]]; then return; fi
|
||||
@@ -1628,11 +1654,22 @@ prompt_virtualenv() {
|
||||
}
|
||||
|
||||
################################################################
|
||||
# pyenv: current active python version (with restrictions)
|
||||
# Segment to display pyenv information
|
||||
# https://github.com/pyenv/pyenv#choosing-the-python-version
|
||||
set_default POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW false
|
||||
prompt_pyenv() {
|
||||
if [[ -n "$PYENV_VERSION" ]]; then
|
||||
"$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$PYENV_VERSION" 'PYTHON_ICON'
|
||||
elif [ $commands[pyenv] ]; then
|
||||
local pyenv_version_name="$(pyenv version-name)"
|
||||
local pyenv_global="system"
|
||||
local pyenv_root="$(pyenv root)"
|
||||
if [[ -f "${pyenv_root}/version" ]]; then
|
||||
pyenv_global="$(pyenv version-file-read ${pyenv_root}/version)"
|
||||
fi
|
||||
if [[ "${pyenv_version_name}" != "${pyenv_global}" || "${POWERLEVEL9K_PYENV_PROMPT_ALWAYS_SHOW}" == "true" ]]; then
|
||||
"$1_prompt_segment" "$0" "$2" "blue" "$DEFAULT_COLOR" "$pyenv_version_name" 'PYTHON_ICON'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1779,10 +1816,16 @@ powerlevel9k_preexec() {
|
||||
|
||||
set_default POWERLEVEL9K_PROMPT_ADD_NEWLINE false
|
||||
powerlevel9k_prepare_prompts() {
|
||||
local RETVAL RPROMPT_PREFIX RPROMPT_SUFFIX
|
||||
# Return values. These need to be global, because
|
||||
# they are used in prompt_status. Also, we need
|
||||
# to get the return value of the last command at
|
||||
# very first in this function. Do not move the
|
||||
# lines down, otherwise the last command is not
|
||||
# what you expected it to be.
|
||||
RETVAL=$?
|
||||
RETVALS=( "$pipestatus[@]" )
|
||||
|
||||
local RPROMPT_SUFFIX RPROMPT_PREFIX
|
||||
_P9K_COMMAND_DURATION=$((EPOCHREALTIME - _P9K_TIMER_START))
|
||||
|
||||
# Reset start time
|
||||
@@ -1868,7 +1911,7 @@ prompt_powerlevel9k_setup() {
|
||||
fi
|
||||
fi
|
||||
|
||||
defined POWERLEVEL9K_LEFT_PROMPT_ELEMENTS || POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir rbenv vcs)
|
||||
defined POWERLEVEL9K_LEFT_PROMPT_ELEMENTS || POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir vcs)
|
||||
defined POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS || POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
|
||||
|
||||
# Display a warning if deprecated segments are in use.
|
||||
|
File diff suppressed because it is too large
Load Diff
1
.zprezto/modules/prompt/external/powerlevel9k/prompt_powerlevel9k_setup
vendored
Symbolic link
1
.zprezto/modules/prompt/external/powerlevel9k/prompt_powerlevel9k_setup
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
powerlevel9k.zsh-theme
|
46
.zprezto/modules/prompt/external/powerlevel9k/shunit2/CODE_OF_CONDUCT.md
vendored
Normal file
46
.zprezto/modules/prompt/external/powerlevel9k/shunit2/CODE_OF_CONDUCT.md
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at kate.ward@forestent.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
201
.zprezto/modules/prompt/external/powerlevel9k/shunit2/LICENSE
vendored
Normal file
201
.zprezto/modules/prompt/external/powerlevel9k/shunit2/LICENSE
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright {yyyy} {name of copyright owner}
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
434
.zprezto/modules/prompt/external/powerlevel9k/shunit2/README.md
vendored
Normal file
434
.zprezto/modules/prompt/external/powerlevel9k/shunit2/README.md
vendored
Normal file
@@ -0,0 +1,434 @@
|
||||
# shUnit2
|
||||
|
||||
shUnit2 is a [xUnit](http://en.wikipedia.org/wiki/XUnit) unit test framework for Bourne based shell scripts, and it is designed to work in a similar manner to [JUnit](http://www.junit.org), [PyUnit](http://pyunit.sourceforge.net), etc.. If you have ever had the desire to write a unit test for a shell script, shUnit2 can do the job.
|
||||
|
||||
[](https://travis-ci.org/kward/shunit2)
|
||||
|
||||
## Table of Contents
|
||||
* [Introduction](#introduction)
|
||||
* [Credits / Contributors](#credits-contributors)
|
||||
* [Feedback](#feedback)
|
||||
* [Quickstart](#quickstart)
|
||||
* [Function Reference](#function-reference)
|
||||
* [General Info](#general-info)
|
||||
* [Asserts](#asserts)
|
||||
* [Failures](#failures)
|
||||
* [Setup/Teardown](#setup-teardown)
|
||||
* [Skipping](#skipping)
|
||||
* [Suites](#suites)
|
||||
* [Advanced Usage](#advanced-usage)
|
||||
* [Some constants you can use](#some-constants-you-can-use)
|
||||
* [Error Handling](#error-handling)
|
||||
* [Including Line Numbers in Asserts (Macros)](#including-line-numbers-in-asserts-macros)
|
||||
* [Test Skipping](#test-skipping)
|
||||
* [Appendix](#appendix)
|
||||
* [Getting help](#getting-help)
|
||||
* [Zsh](#zsh)
|
||||
|
||||
---
|
||||
## <a name="introduction"></a> Introduction
|
||||
shUnit2 was originally developed to provide a consistent testing solution for [log4sh][log4sh], a shell based logging framework similar to [log4j](http://logging.apache.org). During the development of that product, a repeated problem of having things work just fine under one shell (`/bin/bash` on Linux to be specific), and then not working under another shell (`/bin/sh` on Solaris) kept coming up. Although several simple tests were run, they were not adequate and did not catch some corner cases. The decision was finally made to write a proper unit test framework after multiple brown-bag releases were made. _Research was done to look for an existing product that met the testing requirements, but no adequate product was found._
|
||||
|
||||
Tested Operating Systems (varies over time)
|
||||
|
||||
* Cygwin
|
||||
* FreeBSD (user supported)
|
||||
* Linux (Gentoo, Ubuntu)
|
||||
* Mac OS X
|
||||
* Solaris 8, 9, 10 (inc. OpenSolaris)
|
||||
|
||||
Tested Shells
|
||||
|
||||
* Bourne Shell (__sh__)
|
||||
* BASH - GNU Bourne Again SHell (__bash__)
|
||||
* DASH (__dash__)
|
||||
* Korn Shell (__ksh__)
|
||||
* pdksh - Public Domain Korn Shell (__pdksh__)
|
||||
* zsh - Zsh (__zsh__) (since 2.1.2) _please see the Zsh shell errata for more information_
|
||||
|
||||
See the appropriate Release Notes for this release (`doc/RELEASE_NOTES-X.X.X.txt`) for the list of actual versions tested.
|
||||
|
||||
### <a name="credits-contributors"></a> Credits / Contributors
|
||||
A list of contributors to shUnit2 can be found in `doc/contributors.md`. Many thanks go out to all those who have contributed to make this a better tool.
|
||||
|
||||
shUnit2 is the original product of many hours of work by Kate Ward, the primary author of the code. For related software, check out https://github.com/kward.
|
||||
|
||||
### <a name="feedback"></a> Feedback
|
||||
Feedback is most certainly welcome for this document. Send your additions, comments and criticisms to the shunit2-users@google.com mailing list.
|
||||
|
||||
---
|
||||
|
||||
## <a name="quickstart"></a> Quickstart
|
||||
This section will give a very quick start to running unit tests with shUnit2. More information is located in later sections.
|
||||
|
||||
Here is a quick sample script to show how easy it is to write a unit test in shell. _Note: the script as it stands expects that you are running it from the "examples" directory._
|
||||
|
||||
```sh
|
||||
#! /bin/sh
|
||||
# file: examples/equality_test.sh
|
||||
|
||||
testEquality() {
|
||||
assertEquals 1 1
|
||||
}
|
||||
|
||||
# Load shUnit2.
|
||||
. ./shunit2
|
||||
```
|
||||
|
||||
Running the unit test should give results similar to the following.
|
||||
|
||||
```console
|
||||
$ cd examples
|
||||
$ ./equality_test.sh
|
||||
testEquality
|
||||
|
||||
Ran 1 test.
|
||||
|
||||
OK
|
||||
```
|
||||
|
||||
W00t! You've just run your first successful unit test. So, what just happened? Quite a bit really, and it all happened simply by sourcing the `shunit2` library. The basic functionality for the script above goes like this:
|
||||
|
||||
* When shUnit2 is sourced, it will walk through any functions defined whose name starts with the string `test`, and add those to an internal list of tests to execute. Once a list of test functions to be run has been determined, shunit2 will go to work.
|
||||
* Before any tests are executed, shUnit2 again looks for a function, this time one named `oneTimeSetUp()`. If it exists, it will be run. This function is normally used to setup the environment for all tests to be run. Things like creating directories for output or setting environment variables are good to place here. Just so you know, you can also declare a corresponding function named `oneTimeTearDown()` function that does the same thing, but once all the tests have been completed. It is good for removing temporary directories, etc.
|
||||
* shUnit2 is now ready to run tests. Before doing so though, it again looks for another function that might be declared, one named `setUp()`. If the function exists, it will be run before each test. It is good for resetting the environment so that each test starts with a clean slate. **At this stage, the first test is finally run.** The success of the test is recorded for a report that will be generated later. After the test is run, shUnit2 looks for a final function that might be declared, one named `tearDown()`. If it exists, it will be run after each test. It is a good place for cleaning up after each test, maybe doing things like removing files that were created, or removing directories. This set of steps, `setUp() > test() > tearDown()`, is repeated for all of the available tests.
|
||||
* Once all the work is done, shUnit2 will generate the nice report you saw above. A summary of all the successes and failures will be given so that you know how well your code is doing.
|
||||
|
||||
We should now try adding a test that fails. Change your unit test to look like this.
|
||||
|
||||
```sh
|
||||
#! /bin/sh
|
||||
# file: examples/party_test.sh
|
||||
|
||||
testEquality() {
|
||||
assertEquals 1 1
|
||||
}
|
||||
|
||||
testPartyLikeItIs1999() {
|
||||
year=`date '+%Y'`
|
||||
assertEquals "It's not 1999 :-(" '1999' "${year}"
|
||||
}
|
||||
|
||||
# Load shUnit2.
|
||||
. ./shunit2
|
||||
```
|
||||
|
||||
So, what did you get? I guess it told you that this isn't 1999. Bummer, eh? Hopefully, you noticed a couple of things that were different about the second test. First, we added an optional message that the user will see if the assert fails. Second, we did comparisons of strings instead of integers as in the first test. It doesn't matter whether you are testing for equality of strings or integers. Both work equally well with shUnit2.
|
||||
|
||||
Hopefully, this is enough to get you started with unit testing. If you want a ton more examples, take a look at the tests provided with [log4sh][log4sh] or [shFlags][shflags]. Both provide excellent examples of more advanced usage. shUnit2 was after all written to meet the unit testing need that [log4sh][log4sh] had.
|
||||
|
||||
---
|
||||
|
||||
## <a name="function-reference"></a> Function Reference
|
||||
|
||||
### <a name="general-info"></a> General Info
|
||||
|
||||
Any string values passed should be properly quoted -- they should must be surrounded by single-quote (`'`) or double-quote (`"`) characters -- so that the shell will properly parse them.
|
||||
|
||||
### <a name="asserts"></a> Asserts
|
||||
|
||||
`assertEquals [message] expected actual`
|
||||
|
||||
Asserts that _expected_ and _actual_ are equal to one another. The _expected_ and _actual_ values can be either strings or integer values as both will be treated as strings. The _message_ is optional, and must be quoted.
|
||||
|
||||
`assertNotEquals [message] unexpected actual`
|
||||
|
||||
Asserts that _unexpected_ and _actual_ are not equal to one another. The _unexpected_ and _actual_ values can be either strings or integer values as both will be treaded as strings. The _message_ is optional, and must be quoted.
|
||||
|
||||
`assertSame [message] expected actual`
|
||||
|
||||
This function is functionally equivalent to `assertEquals`.
|
||||
|
||||
`assertNotSame [message] unexpected actual`
|
||||
|
||||
This function is functionally equivalent to `assertNotEquals`.
|
||||
|
||||
`assertNull [message] value`
|
||||
|
||||
Asserts that _value_ is _null_, or in shell terms, a zero-length string. The _value_ must be a string as an integer value does not translate into a zero-length string. The _message_ is optional, and must be quoted.
|
||||
|
||||
`assertNotNull [message] value`
|
||||
|
||||
Asserts that _value_ is _not null_, or in shell terms, a non-empty string. The _value_ may be a string or an integer as the later will be parsed as a non-empty string value. The _message_ is optional, and must be quoted.
|
||||
|
||||
`assertTrue [message] condition`
|
||||
|
||||
Asserts that a given shell test _condition_ is _true_. The condition can be as simple as a shell _true_ value (the value `0` -- equivalent to `${SHUNIT_TRUE}`), or a more sophisticated shell conditional expression. The _message_ is optional, and must be quoted.
|
||||
|
||||
A sophisticated shell conditional expression is equivalent to what the __if__ or __while__ shell built-ins would use (more specifically, what the __test__ command would use). Testing for example whether some value is greater than another value can be done this way.
|
||||
|
||||
`assertTrue "[ 34 -gt 23 ]"`
|
||||
|
||||
Testing for the ability to read a file can also be done. This particular test will fail.
|
||||
|
||||
`assertTrue 'test failed' "[ -r /some/non-existant/file' ]"`
|
||||
|
||||
As the expressions are standard shell __test__ expressions, it is possible to string multiple expressions together with `-a` and `-o` in the standard fashion. This test will succeed as the entire expression evaluates to _true_.
|
||||
|
||||
`assertTrue 'test failed' '[ 1 -eq 1 -a 2 -eq 2 ]'`
|
||||
|
||||
_One word of warning: be very careful with your quoting as shell is not the most forgiving of bad quoting, and things will fail in strange ways._
|
||||
|
||||
`assertFalse [message] condition`
|
||||
|
||||
Asserts that a given shell test _condition_ is _false_. The condition can be as simple as a shell _false_ value (the value `1` -- equivalent to `${SHUNIT_FALSE}`), or a more sophisticated shell conditional expression. The _message_ is optional, and must be quoted.
|
||||
|
||||
_For examples of more sophisticated expressions, see `assertTrue`._
|
||||
|
||||
### <a name="failures"></a> Failures
|
||||
|
||||
Just to clarify, failures __do not__ test the various arguments against one another. Failures simply fail, optionally with a message, and that is all they do. If you need to test arguments against one another, use asserts.
|
||||
|
||||
If all failures do is fail, why might one use them? There are times when you may have some very complicated logic that you need to test, and the simple asserts provided are simply not adequate. You can do your own validation of the code, use an `assertTrue ${SHUNIT_TRUE}` if your own tests succeeded, and use a failure to record a failure.
|
||||
|
||||
`fail [message]`
|
||||
|
||||
Fails the test immediately. The _message_ is optional, and must be quoted.
|
||||
|
||||
`failNotEquals [message] unexpected actual`
|
||||
|
||||
Fails the test immediately, reporting that the _unexpected_ and _actual_ values are not equal to one another. The _message_ is optional, and must be quoted.
|
||||
|
||||
_Note: no actual comparison of unexpected and actual is done._
|
||||
|
||||
`failSame [message] expected actual`
|
||||
|
||||
Fails the test immediately, reporting that the _expected_ and _actual_ values are the same. The _message_ is optional, and must be quoted.
|
||||
|
||||
_Note: no actual comparison of expected and actual is done._
|
||||
|
||||
`failNotSame [message] expected actual`
|
||||
|
||||
Fails the test immediately, reporting that the _expected_ and _actual_ values are not the same. The _message_ is optional, and must be quoted.
|
||||
|
||||
_Note: no actual comparison of expected and actual is done._
|
||||
|
||||
### <a name="setup-teardown"></a> Setup/Teardown
|
||||
|
||||
`oneTimeSetUp`
|
||||
|
||||
This function can be be optionally overridden by the user in their test suite.
|
||||
|
||||
If this function exists, it will be called once before any tests are run. It is useful to prepare a common environment for all tests.
|
||||
|
||||
`oneTimeTearDown`
|
||||
|
||||
This function can be be optionally overridden by the user in their test suite.
|
||||
|
||||
If this function exists, it will be called once after all tests are completed. It is useful to clean up the environment after all tests.
|
||||
|
||||
`setUp`
|
||||
|
||||
This function can be be optionally overridden by the user in their test suite.
|
||||
|
||||
If this function exists, it will be called before each test is run. It is useful to reset the environment before each test.
|
||||
|
||||
`tearDown`
|
||||
|
||||
This function can be be optionally overridden by the user in their test suite.
|
||||
|
||||
If this function exists, it will be called after each test completes. It is useful to clean up the environment after each test.
|
||||
|
||||
### <a name="skipping"></a> Skipping
|
||||
|
||||
`startSkipping`
|
||||
|
||||
This function forces the remaining _assert_ and _fail_ functions to be "skipped", i.e. they will have no effect. Each function skipped will be recorded so that the total of asserts and fails will not be altered.
|
||||
|
||||
`endSkipping`
|
||||
|
||||
This function returns calls to the _assert_ and _fail_ functions to their default behavior, i.e. they will be called.
|
||||
|
||||
`isSkipping`
|
||||
|
||||
This function returns the current state of skipping. It can be compared against `${SHUNIT_TRUE}` or `${SHUNIT_FALSE}` if desired.
|
||||
|
||||
### <a name="suites"></a> Suites
|
||||
|
||||
The default behavior of shUnit2 is that all tests will be found dynamically. If you have a specific set of tests you want to run, or you don't want to use the standard naming scheme of prefixing your tests with `test`, these functions are for you. Most users will never use them though.
|
||||
|
||||
`suite`
|
||||
|
||||
This function can be optionally overridden by the user in their test suite.
|
||||
|
||||
If this function exists, it will be called when `shunit2` is sourced. If it does not exist, shUnit2 will search the parent script for all functions beginning with the word `test`, and they will be added dynamically to the test suite.
|
||||
|
||||
`suite_addTest name`
|
||||
|
||||
This function adds a function named _name_ to the list of tests scheduled for execution as part of this test suite. This function should only be called from within the `suite()` function.
|
||||
|
||||
---
|
||||
|
||||
## <a name="advanced-usage"></a> Advanced Usage
|
||||
|
||||
### <a name="some-constants-you-can-use"></a> Some constants you can use
|
||||
|
||||
There are several constants provided by shUnit2 as variables that might be of use to you.
|
||||
|
||||
*Predefined*
|
||||
|
||||
| Constant | Value |
|
||||
| --------------- | ----- |
|
||||
| SHUNIT\_TRUE | Standard shell `true` value (the integer value 0). |
|
||||
| SHUNIT\_FALSE | Standard shell `false` value (the integer value 1). |
|
||||
| SHUNIT\_ERROR | The integer value 2. |
|
||||
| SHUNIT\_TMPDIR | Path to temporary directory that will be automatically cleaned up upon exit of shUnit2. |
|
||||
| SHUNIT\_VERSION | The version of shUnit2 you are running. |
|
||||
|
||||
*User defined*
|
||||
|
||||
| Constant | Value |
|
||||
| ----------------- | ----- |
|
||||
| SHUNIT\_CMD\_EXPR | Override which `expr` command is used. By default `expr` is used, except on BSD systems where `gexpr` is used. |
|
||||
| SHUNIT\_COLOR | Enable colorized output. Options are 'auto', 'always', or 'never', with 'auto' being the default. |
|
||||
| SHUNIT\_PARENT | The filename of the shell script containing the tests. This is needed specifically for Zsh support. |
|
||||
| SHUNIT\_TEST\_PREFIX | Define this variable to add a prefix in front of each test name that is output in the test report. |
|
||||
|
||||
### <a name="error-handling"></a> Error handling
|
||||
|
||||
The constants values `SHUNIT_TRUE`, `SHUNIT_FALSE`, and `SHUNIT_ERROR` are returned from nearly every function to indicate the success or failure of the function. Additionally the variable `flags_error` is filled with a detailed error message if any function returns with a `SHUNIT_ERROR` value.
|
||||
|
||||
### <a name="including-line-numbers-in-asserts-macros"></a> Including Line Numbers in Asserts (Macros)
|
||||
|
||||
If you include lots of assert statements in an individual test function, it can become difficult to determine exactly which assert was thrown unless your messages are unique. To help somewhat, line numbers can be included in the assert messages. To enable this, a special shell "macro" must be used rather than the standard assert calls. _Shell doesn't actually have macros; the name is used here as the operation is similar to a standard macro._
|
||||
|
||||
For example, to include line numbers for a `assertEquals()` function call, replace the `assertEquals()` with `${_ASSERT_EQUALS_}`.
|
||||
|
||||
_**Example** -- Asserts with and without line numbers_
|
||||
```sh
|
||||
#! /bin/sh
|
||||
# file: examples/lineno_test.sh
|
||||
|
||||
testLineNo() {
|
||||
# This assert will have line numbers included (e.g. "ASSERT:[123] ...").
|
||||
echo "ae: ${_ASSERT_EQUALS_}"
|
||||
${_ASSERT_EQUALS_} 'not equal' 1 2
|
||||
|
||||
# This assert will not have line numbers included (e.g. "ASSERT: ...").
|
||||
assertEquals 'not equal' 1 2
|
||||
}
|
||||
|
||||
# Load shUnit2.
|
||||
. ./shunit2
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
1. Due to how shell parses command-line arguments, all strings used with macros should be quoted twice. Namely, single-quotes must be converted to single-double-quotes, and vice-versa. If the string being passed is absolutely for sure not empty, the extra quoting is not necessary.<br/><br/>Normal `assertEquals` call.<br/>`assertEquals 'some message' 'x' ''`<br/><br/>Macro `_ASSERT_EQUALS_` call. Note the extra quoting around the _message_ and the _null_ value.<br/>`_ASSERT_EQUALS_ '"some message"' 'x' '""'`
|
||||
|
||||
1. Line numbers are not supported in all shells. If a shell does not support them, no errors will be thrown. Supported shells include: __bash__ (>=3.0), __ksh__, __pdksh__, and __zsh__.
|
||||
|
||||
### <a name="test-skipping"></a> Test Skipping
|
||||
|
||||
There are times where the test code you have written is just not applicable to the system you are running on. This section describes how to skip these tests but maintain the total test count.
|
||||
|
||||
Probably the easiest example would be shell code that is meant to run under the __bash__ shell, but the unit test is running under the Bourne shell. There are things that just won't work. The following test code demonstrates two sample functions, one that will be run under any shell, and the another that will run only under the __bash__ shell.
|
||||
|
||||
_**Example** -- math include_
|
||||
```sh
|
||||
# file: examples/math.inc.
|
||||
|
||||
add_generic() {
|
||||
num_a=$1
|
||||
num_b=$2
|
||||
|
||||
expr $1 + $2
|
||||
}
|
||||
|
||||
add_bash() {
|
||||
num_a=$1
|
||||
num_b=$2
|
||||
|
||||
echo $(($1 + $2))
|
||||
}
|
||||
```
|
||||
|
||||
And here is a corresponding unit test that correctly skips the `add_bash()` function when the unit test is not running under the __bash__ shell.
|
||||
|
||||
_**Example** -- math unit test_
|
||||
```sh
|
||||
#! /bin/sh
|
||||
# file: examples/math_test.sh
|
||||
|
||||
testAdding() {
|
||||
result=`add_generic 1 2`
|
||||
assertEquals \
|
||||
"the result of '${result}' was wrong" \
|
||||
3 "${result}"
|
||||
|
||||
# Disable non-generic tests.
|
||||
[ -z "${BASH_VERSION:-}" ] && startSkipping
|
||||
|
||||
result=`add_bash 1 2`
|
||||
assertEquals \
|
||||
"the result of '${result}' was wrong" \
|
||||
3 "${result}"
|
||||
}
|
||||
|
||||
oneTimeSetUp() {
|
||||
# Load include to test.
|
||||
. ./math.inc
|
||||
}
|
||||
|
||||
# Load and run shUnit2.
|
||||
. ./shunit2
|
||||
```
|
||||
|
||||
Running the above test under the __bash__ shell will result in the following output.
|
||||
|
||||
```console
|
||||
$ /bin/bash math_test.sh
|
||||
testAdding
|
||||
|
||||
Ran 1 test.
|
||||
|
||||
OK
|
||||
```
|
||||
|
||||
But, running the test under any other Unix shell will result in the following output.
|
||||
|
||||
```console
|
||||
$ /bin/ksh math_test.sh
|
||||
testAdding
|
||||
|
||||
Ran 1 test.
|
||||
|
||||
OK (skipped=1)
|
||||
```
|
||||
|
||||
As you can see, the total number of tests has not changed, but the report indicates that some tests were skipped.
|
||||
|
||||
Skipping can be controlled with the following functions: `startSkipping()`, `endSkipping()`, and `isSkipping()`. Once skipping is enabled, it will remain enabled until the end of the current test function call, after which skipping is disabled.
|
||||
|
||||
---
|
||||
|
||||
## <a name="appendix"></a> Appendix
|
||||
|
||||
### <a name="getting-help"></a> Getting Help
|
||||
|
||||
For help, please send requests to either the shunit2-users@googlegroups.com mailing list (archives available on the web at http://groups.google.com/group/shunit2-users) or directly to Kate Ward <kate dot ward at forestent dot com>.
|
||||
|
||||
### <a name="zsh"></a> Zsh
|
||||
|
||||
For compatibility with Zsh, there is one requirement that must be met -- the `shwordsplit` option must be set. There are three ways to accomplish this.
|
||||
|
||||
1. In the unit-test script, add the following shell code snippet before sourcing the `shunit2` library.
|
||||
|
||||
```sh
|
||||
setopt shwordsplit
|
||||
```
|
||||
|
||||
1. When invoking __zsh__ from either the command-line or as a script with `#!`, add the `-y` parameter.
|
||||
|
||||
```sh
|
||||
#! /bin/zsh -y
|
||||
```
|
||||
|
||||
1. When invoking __zsh__ from the command-line, add `-o shwordsplit --` as parameters before the script name.
|
||||
|
||||
```console
|
||||
$ zsh -o shwordsplit -- some_script
|
||||
```
|
||||
|
||||
[log4sh]: https://github.com/kward/log4sh
|
||||
[shflags]: https://github.com/kward/shflags
|
@@ -1,14 +1,53 @@
|
||||
Changes in shUnit2 2.1.X
|
||||
========================
|
||||
# shUnit2 2.1.x Changes
|
||||
|
||||
Changes with 2.1.7
|
||||
------------------
|
||||
## Changes with 2.1.8
|
||||
|
||||
Updated the LGPL license from http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt.
|
||||
### Enhancements
|
||||
|
||||
Issue #29. Add support for user defined prefix for test names. A prefix can be added by defining the `SHUNIT_TEST_PREFIX` variable.
|
||||
|
||||
Issue #78. Added an example for using suite tests.
|
||||
|
||||
Run continuous integration additionally against Ubuntu Trusty.
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Issue #84. Treat syntax errors in functions as test failures.
|
||||
|
||||
Issue #77. Fail tests when the environment functions (e.g. `setup()` or `tearDown()`) fail.
|
||||
|
||||
## Changes with 2.1.7
|
||||
|
||||
### Bug fixes
|
||||
|
||||
Issue #69. shUnit2 should not exit with 0 when it has (syntax) errors.
|
||||
|
||||
### Enhancements
|
||||
|
||||
Issue #54. Shell commands prefixed with '\' so that they can be stubbed in
|
||||
tests.
|
||||
|
||||
Issue #68. Ran all code through [ShellCheck](http://www.shellcheck.net/).
|
||||
|
||||
Issue #60. Continuous integration tests now run with
|
||||
[Travis CI](https://travis-ci.org/kward/shunit2).
|
||||
|
||||
Issue #56. Added color support. Color is enabled automatically when supported,
|
||||
but can be disabled by defining the SHUNIT_COLOR environment variable before
|
||||
sourcing shunit2. Accepted values are `always`, `auto` (the default), and
|
||||
`none`.
|
||||
|
||||
Issue #35. Add colored output.
|
||||
|
||||
### Other
|
||||
|
||||
Moved code to GitHub (https://github.com/kward/shunit2), and restructured to
|
||||
be more GitHub like.
|
||||
|
||||
Changed to the Apache 2.0 license.
|
||||
|
||||
|
||||
Changes with 2.1.6
|
||||
------------------
|
||||
## Changes with 2.1.6
|
||||
|
||||
Removed all references to the DocBook documentation.
|
||||
|
||||
@@ -18,11 +57,11 @@ Fixed error message in fail() that stated wrong number of required arguments.
|
||||
|
||||
Updated lib/versions.
|
||||
|
||||
Fixed bug in _shunit_mktempDir() where a failure occurred when the 'od' command
|
||||
was not present in /usr/bin.
|
||||
Fixed bug in `_shunit_mktempDir()` where a failure occurred when the 'od'
|
||||
command was not present in `/usr/bin`.
|
||||
|
||||
Renamed shunit_tmpDir variable to SHUNIT_TMPDIR to closer match the standard
|
||||
TMPDIR variable.
|
||||
Renamed `shunit_tmpDir` variable to `SHUNIT_TMPDIR` to closer match the standard
|
||||
`TMPDIR` variable.
|
||||
|
||||
Added support for calling shunit2 as an executable, in addition to the existing
|
||||
method of sourcing it in as a library. This allows users to keep tests working
|
||||
@@ -32,56 +71,55 @@ distribution.
|
||||
Issue #14: Improved handling of some strange chars (e.g. single and double
|
||||
quotes) in messages.
|
||||
|
||||
Issue# 27: Fixed error message for assertSame().
|
||||
Issue# 27: Fixed error message for `assertSame()`.
|
||||
|
||||
Issue# 25: Added check and error message to user when phantom functions are
|
||||
written to a partition mounted with noexec.
|
||||
written to a partition mounted with `noexec`.
|
||||
|
||||
Issue# 11: Added support for defining functions like 'function someFunction()'.
|
||||
Issue# 11: Added support for defining functions like `function someFunction()`.
|
||||
|
||||
|
||||
Changes with 2.1.5
|
||||
------------------
|
||||
## Changes with 2.1.5
|
||||
|
||||
Issue# 1: Fixed bug pointed out by R Bernstein in the trap code where certain
|
||||
types of exit conditions did not generate the ending report.
|
||||
|
||||
Issue# 2: Added assertNotEquals() assert.
|
||||
Issue# 2: Added `assertNotEquals()` assert.
|
||||
|
||||
Issue# 3: Moved check for unset variables out of shUnit2 into the unit tests.
|
||||
Testing poorly written software blows up if this check is in, but it is only
|
||||
interesting for shUnit2 itself. Added shunit_test_output.sh unit test for this.
|
||||
Some shells still do not catch such errors properly (e.g. Bourne shell and BASH
|
||||
2.x).
|
||||
interesting for shUnit2 itself. Added `shunit_test_output.sh` unit test for
|
||||
this. Some shells still do not catch such errors properly (e.g. Bourne shell and
|
||||
BASH 2.x).
|
||||
|
||||
Added new custom assert in test_helpers to check for output to STDOUT, and none
|
||||
to STDERR.
|
||||
|
||||
Replaced fatal message in the temp directory creation with a _shunit_fatal()
|
||||
Replaced fatal message in the temp directory creation with a `_shunit_fatal()`
|
||||
function call.
|
||||
|
||||
Fixed test_output unit test so it works now that the 'set -u' stuff was removed
|
||||
for Issue# 3.
|
||||
|
||||
Flushed out the coding standards in the README.txt a bit more, and brought the
|
||||
Flushed out the coding standards in the `README.txt` a bit more, and brought the
|
||||
shunit2 code up to par with the documented standards.
|
||||
|
||||
Issue# 4: Completely changed the reporting output to be a closer match for
|
||||
JUnit and PyUnit. As a result, tests are counted separately from assertions.
|
||||
|
||||
Provide public shunit_tmpDir variable that can be used by unit test scripts that
|
||||
need automated and guaranteed cleanup.
|
||||
Provide public `shunit_tmpDir` variable that can be used by unit test scripts
|
||||
that need automated and guaranteed cleanup.
|
||||
|
||||
Issue# 7: Fixed duplicated printing of messages passed to asserts.
|
||||
|
||||
Per code review, fixed wording of failSame() and failNotSame() messages.
|
||||
Per code review, fixed wording of `failSame()` and `failNotSame()` messages.
|
||||
|
||||
Replaced version_info.sh with versions library and made appropriate changes in
|
||||
Replaced `version_info.sh` with versions library and made appropriate changes in
|
||||
other scripts to use it.
|
||||
|
||||
Added gen_test_results.sh to make releases easier.
|
||||
Added `gen_test_results.sh` to make releases easier.
|
||||
|
||||
Fixed bugs in shlib_relToAbsPath() in shlib.
|
||||
Fixed bugs in `shlib_relToAbsPath()` in shlib.
|
||||
|
||||
Converted DocBook documentation to reStructuredText for easier maintenance. The
|
||||
DocBook documentation is now considered obsolete, and will be removed in a
|
||||
@@ -97,10 +135,9 @@ When an invalid number of arguments is passed to a function, the invalid number
|
||||
is returned to the user so they are more aware of what the cause might be.
|
||||
|
||||
|
||||
Changes with 2.1.4
|
||||
------------------
|
||||
## Changes with 2.1.4
|
||||
|
||||
Removed the _shunit_functionExists() function as it was dead code.
|
||||
Removed the `_shunit_functionExists()` function as it was dead code.
|
||||
|
||||
Fixed zsh version number check in version_info.
|
||||
|
||||
@@ -123,11 +160,10 @@ result.
|
||||
|
||||
Improved zsh version and option checks.
|
||||
|
||||
Renamed the __SHUNIT_VERSION variable to SHUNIT_VERSION.
|
||||
Renamed the `__SHUNIT_VERSION` variable to `SHUNIT_VERSION`.
|
||||
|
||||
|
||||
Changes with 2.1.3
|
||||
------------------
|
||||
## Changes with 2.1.3
|
||||
|
||||
Added some explicit variable defaults, even though the variables are set, as
|
||||
they sometimes behave strange when the script is canceled.
|
||||
@@ -141,29 +177,27 @@ considered failures, and do not affect the exit code.
|
||||
Changed detection of STDERR output in unit tests.
|
||||
|
||||
|
||||
Changes with 2.1.2
|
||||
------------------
|
||||
## Changes with 2.1.2
|
||||
|
||||
Unset additional variables that were missed.
|
||||
|
||||
Added checks and workarounds to improve zsh compatibility.
|
||||
|
||||
Added some argument count checks ``assertEquals()``, ``assertNull()``, and
|
||||
``assertSame()``
|
||||
Added some argument count checks `assertEquals()`, `assertNull()`, and
|
||||
`assertSame()`.
|
||||
|
||||
|
||||
Changes with 2.1.1
|
||||
------------------
|
||||
## Changes with 2.1.1
|
||||
|
||||
Fixed bug where ``fail()`` was not honoring skipping.
|
||||
Fixed bug where `fail()` was not honoring skipping.
|
||||
|
||||
Fixed problem with ``docs-docbook-prep`` target that prevented it from working.
|
||||
Fixed problem with `docs-docbook-prep` target that prevented it from working.
|
||||
(Thanks to Bryan Larsen for pointing this out.)
|
||||
|
||||
Changed the test in ``assertFalse()`` so that any non-zero value registers as
|
||||
Changed the test in `assertFalse()` so that any non-zero value registers as
|
||||
false. (Credits to Bryan Larsen)
|
||||
|
||||
Major fiddling to bring more in line with `JUnit <http://junit.org/>`. Asserts
|
||||
Major fiddling to bring more in line with [JUnit](http://junit.org/). Asserts
|
||||
give better output when no message is given, and failures now just fail.
|
||||
|
||||
It was pointed out that the simple 'failed' message for a failed assert was not
|
||||
@@ -172,7 +206,7 @@ provide the user with an expected vs actual result. The code was revised
|
||||
somewhat to bring closer into alignment with JUnit (v4.3.1 specifically) so
|
||||
that it feels more "normal". (Credits to Richard Jensen)
|
||||
|
||||
As part of the JUnit realignment, it was noticed that fail*() functions in
|
||||
As part of the JUnit realignment, it was noticed that `fail*()` functions in
|
||||
JUnit don't actually do any comparisons themselves. They only generate a
|
||||
failure message. Updated the code to match.
|
||||
|
||||
@@ -193,29 +227,27 @@ Fixed the method of percent calculation for the report to get achieve better
|
||||
accuracy.
|
||||
|
||||
|
||||
Changes with 2.1.0 (since 2.0.1)
|
||||
--------------------------------
|
||||
## Changes with 2.1.0 (since 2.0.1)
|
||||
|
||||
This release is a branch of the 2.0.1 release.
|
||||
|
||||
Moving to `reStructured Text <http://docutils.sourceforge.net/rst.html>`_ for
|
||||
Moving to [reStructured Text](http://docutils.sourceforge.net/rst.html) for
|
||||
the documentation.
|
||||
|
||||
Fixed problem with ``fail()``. The failure message was not properly printed.
|
||||
Fixed problem with `fail()`. The failure message was not properly printed.
|
||||
|
||||
Fixed the ``Makefile`` so that the DocBook XML and XSLT files would be
|
||||
Fixed the `Makefile` so that the DocBook XML and XSLT files would be
|
||||
downloaded before parsing can continue.
|
||||
|
||||
Renamed the internal ``__SHUNIT_TRUE`` and ``__SHUNIT_FALSE`` variables to
|
||||
``SHUNIT_TRUE`` and ``SHUNIT_FALSE`` so that unit tests can "use" them.
|
||||
Renamed the internal `__SHUNIT_TRUE` and `__SHUNIT_FALSE` variables to
|
||||
`SHUNIT_TRUE` and `SHUNIT_FALSE` so that unit tests can "use" them.
|
||||
|
||||
Added support for test "skipping". If skipping is turned on with the
|
||||
``startSkip()`` function, ``assert`` and ``fail`` functions will return
|
||||
immediately, and the skip will be recorded.
|
||||
`startSkip()` function, `assert` and `fail` functions will return immediately,
|
||||
and the skip will be recorded.
|
||||
|
||||
The report output format was changed to include the percentage for each test
|
||||
result, rather than just those successful.
|
||||
|
||||
|
||||
.. $Revision$
|
||||
.. vim:fileencoding=latin1:ft=text:spell:tw=80
|
62
.zprezto/modules/prompt/external/powerlevel9k/shunit2/doc/RELEASE_NOTES-2.1.7.md
vendored
Normal file
62
.zprezto/modules/prompt/external/powerlevel9k/shunit2/doc/RELEASE_NOTES-2.1.7.md
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# shUnit2 2.1.7 Release Notes
|
||||
|
||||
https://github.com/kward/shunit2
|
||||
|
||||
This release contains bug fixes and enhancements. It is the first release since moving to GitHub. Users can now clone the latest version at any time.
|
||||
|
||||
See the `CHANGES-2.1.md` file for a full list of changes.
|
||||
|
||||
|
||||
## New Features
|
||||
|
||||
Colorized output, based on popular demand. shUnit2 output is now colorized based on the result of the asserts.
|
||||
|
||||
|
||||
## Changes and Enhancements
|
||||
|
||||
With the move to GitHub, the shUnit2 unit tests are run on every commit using the [Travis CI][TravisCI] continuous integration framework. Additionally, all code is run through [ShellCheck](http:/www.shellcheck.net/) on every commit.
|
||||
|
||||
[TravisCI]: https://travis-ci.org/kward/shunit2
|
||||
|
||||
Shell commands in shUnit2 are prefixed with '\' so that they can be stubbed in tests.
|
||||
|
||||
|
||||
## Bug Fixes
|
||||
|
||||
shUnit2 no longer exits with an 'OK' result if there were syntax errors due to incorrect usage of the assert commands.
|
||||
|
||||
|
||||
## Deprecated Features
|
||||
|
||||
None.
|
||||
|
||||
|
||||
## Known Bugs and Issues
|
||||
|
||||
Zsh requires the `shwordsplit` option to be set. See the documentation for examples of how to do this.
|
||||
|
||||
Line numbers in assert messages do not work properly with BASH 2.x.
|
||||
|
||||
The Bourne shell of Solaris, BASH 2.x, and Zsh 3.0.x do not properly catch the
|
||||
SIGTERM signal. As such, shell interpreter failures due to such things as
|
||||
unbound variables cannot be caught. (See `shunit_test_misc.sh`)
|
||||
|
||||
|
||||
## Tested Platforms
|
||||
|
||||
Continuous integration testing is provided by [Travis CI][TravisCI].
|
||||
|
||||
Tested OSes:
|
||||
|
||||
- Linux
|
||||
- macOS
|
||||
|
||||
Tested shells:
|
||||
|
||||
- /bin/sh
|
||||
- ash
|
||||
- bash
|
||||
- dash
|
||||
- ksh
|
||||
- pdksh
|
||||
- zsh
|
15
.zprezto/modules/prompt/external/powerlevel9k/shunit2/doc/contributors.md
vendored
Normal file
15
.zprezto/modules/prompt/external/powerlevel9k/shunit2/doc/contributors.md
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
The original author of shunit2 is Kate Ward. The following people have
|
||||
contributed in some way or another to shunit2.
|
||||
|
||||
- [Alex Harvey](https://github.com/alexharv074)
|
||||
- Bryan Larsen
|
||||
- [David Acacio](https://github.com/dacacioa)
|
||||
- Kevin Van Horn
|
||||
- [Maciej Bliziński](https://github.com/automatthias)
|
||||
- Mario Sparada
|
||||
- Mathias Goldau
|
||||
- Richard Jensen
|
||||
- Rob Holland
|
||||
- Rocky Bernstein
|
||||
- [rugk](https://github.com/rugk)
|
||||
- wood4321 (of code.google.com)
|
@@ -530,7 +530,7 @@ assertTrue "[ 34 -gt 23 ]"
|
||||
<p>Testing for the ability to read a file can also be done. This particular test
|
||||
will fail.</p>
|
||||
<pre class="literal-block">
|
||||
assertTrue 'test failed' "[ -r /some/non-existant/file' ]"
|
||||
assertTrue 'test failed' "[ -r /some/non-existent/file' ]"
|
||||
</pre>
|
||||
<p>As the expressions are standard shell <strong>test</strong> expressions, it is possible to
|
||||
string multiple expressions together with <tt class="docutils literal"><span class="pre">-a</span></tt> and <tt class="docutils literal"><span class="pre">-o</span></tt> in the standard
|
@@ -51,9 +51,9 @@ See the appropriate Release Notes for this release
|
||||
Credits / Contributors
|
||||
----------------------
|
||||
|
||||
A list of contributors to shUnit2 can be found in the source archive in
|
||||
``doc/contributors.txt``. Many thanks go out to all those who have contributed
|
||||
to make this a better tool.
|
||||
A list of contributors to shUnit2 can be found in ``doc/contributors.md``.
|
||||
Many thanks go out to all those who have contributed to make this a better
|
||||
tool.
|
||||
|
||||
shUnit2 is the original product of many hours of work by Kate Ward, the primary
|
||||
author of the code. For other products by her, look up log4sh_ or shFlags_, or
|
||||
@@ -214,7 +214,7 @@ Asserts
|
||||
Testing for the ability to read a file can also be done. This particular test
|
||||
will fail. ::
|
||||
|
||||
assertTrue 'test failed' "[ -r /some/non-existant/file' ]"
|
||||
assertTrue 'test failed' "[ -r /some/non-existent/file' ]"
|
||||
|
||||
As the expressions are standard shell **test** expressions, it is possible to
|
||||
string multiple expressions together with ``-a`` and ``-o`` in the standard
|
||||
@@ -358,6 +358,8 @@ Predefined
|
||||
User defined
|
||||
|
||||
================== ===========================================================
|
||||
``SHUNIT_COLOR`` Set this flag to control colored output support. Accepted
|
||||
values are ``always``, ``auto`` (the default), and ``none``.
|
||||
``SHUNIT_PARENT`` The filename of the shell script containing the tests. This
|
||||
is needed specifically for Zsh support.
|
||||
================== ===========================================================
|
@@ -1,10 +1,9 @@
|
||||
#! /bin/sh
|
||||
# file: examples/equality_test.sh
|
||||
|
||||
testEquality()
|
||||
{
|
||||
testEquality() {
|
||||
assertEquals 1 1
|
||||
}
|
||||
|
||||
# load shunit2
|
||||
. ../src/shunit2
|
||||
# Load and run shUnit2.
|
||||
. ../shunit2
|
15
.zprezto/modules/prompt/external/powerlevel9k/shunit2/examples/lineno_test.sh
vendored
Executable file
15
.zprezto/modules/prompt/external/powerlevel9k/shunit2/examples/lineno_test.sh
vendored
Executable file
@@ -0,0 +1,15 @@
|
||||
#! /bin/sh
|
||||
# file: examples/lineno_test.sh
|
||||
|
||||
testLineNo() {
|
||||
# This assert will have line numbers included (e.g. "ASSERT:[123] ...") if
|
||||
# they are supported.
|
||||
echo "_ASSERT_EQUALS_ macro value: ${_ASSERT_EQUALS_}"
|
||||
${_ASSERT_EQUALS_} '"not equal"' 1 2
|
||||
|
||||
# This assert will not have line numbers included (e.g. "ASSERT: ...").
|
||||
assertEquals 'not equal' 1 2
|
||||
}
|
||||
|
||||
# Load and run shUnit2.
|
||||
. ../shunit2
|
@@ -1,14 +1,13 @@
|
||||
#! /bin/sh
|
||||
# available as examples/math_test.sh
|
||||
# file: examples/math_test.sh
|
||||
|
||||
testAdding()
|
||||
{
|
||||
testAdding() {
|
||||
result=`add_generic 1 2`
|
||||
assertEquals \
|
||||
"the result of '${result}' was wrong" \
|
||||
3 "${result}"
|
||||
|
||||
# disable non-generic tests
|
||||
# Disable non-generic tests.
|
||||
[ -z "${BASH_VERSION:-}" ] && startSkipping
|
||||
|
||||
result=`add_bash 1 2`
|
||||
@@ -17,11 +16,10 @@ testAdding()
|
||||
3 "${result}"
|
||||
}
|
||||
|
||||
oneTimeSetUp()
|
||||
{
|
||||
# load include to test
|
||||
oneTimeSetUp() {
|
||||
# Load include to test.
|
||||
. ./math.inc
|
||||
}
|
||||
|
||||
# load and run shUnit2
|
||||
. ../src/shunit2
|
||||
# Load and run shUnit2.
|
||||
. ../shunit2
|
@@ -12,12 +12,7 @@
|
||||
# example, we will test several aspects of the the mkdir command, but the
|
||||
# techniques could be used for any existing shell script.
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite tests
|
||||
#
|
||||
|
||||
testMissingDirectoryCreation()
|
||||
{
|
||||
testMissingDirectoryCreation() {
|
||||
${mkdirCmd} "${testDir}" >${stdoutF} 2>${stderrF}
|
||||
rtrn=$?
|
||||
th_assertTrueWithNoOutput ${rtrn} "${stdoutF}" "${stderrF}"
|
||||
@@ -25,12 +20,11 @@ testMissingDirectoryCreation()
|
||||
assertTrue 'directory missing' "[ -d '${testDir}' ]"
|
||||
}
|
||||
|
||||
testExistingDirectoryCreationFails()
|
||||
{
|
||||
# create a directory to test against
|
||||
testExistingDirectoryCreationFails() {
|
||||
# Create a directory to test against.
|
||||
${mkdirCmd} "${testDir}"
|
||||
|
||||
# test for expected failure while trying to create directory that exists
|
||||
# Test for expected failure while trying to create directory that exists.
|
||||
${mkdirCmd} "${testDir}" >${stdoutF} 2>${stderrF}
|
||||
rtrn=$?
|
||||
assertFalse 'expecting return code of 1 (false)' ${rtrn}
|
||||
@@ -40,8 +34,7 @@ testExistingDirectoryCreationFails()
|
||||
assertTrue 'directory missing' "[ -d '${testDir}' ]"
|
||||
}
|
||||
|
||||
testRecursiveDirectoryCreation()
|
||||
{
|
||||
testRecursiveDirectoryCreation() {
|
||||
testDir2="${testDir}/test2"
|
||||
|
||||
${mkdirCmd} -p "${testDir2}" >${stdoutF} 2>${stderrF}
|
||||
@@ -52,12 +45,7 @@ testRecursiveDirectoryCreation()
|
||||
assertTrue 'second directory missing' "[ -d '${testDir2}' ]"
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite functions
|
||||
#
|
||||
|
||||
th_assertTrueWithNoOutput()
|
||||
{
|
||||
th_assertTrueWithNoOutput() {
|
||||
th_return_=$1
|
||||
th_stdout_=$2
|
||||
th_stderr_=$3
|
||||
@@ -68,8 +56,7 @@ th_assertTrueWithNoOutput()
|
||||
unset th_return_ th_stdout_ th_stderr_
|
||||
}
|
||||
|
||||
oneTimeSetUp()
|
||||
{
|
||||
oneTimeSetUp() {
|
||||
outputDir="${SHUNIT_TMPDIR}/output"
|
||||
mkdir "${outputDir}"
|
||||
stdoutF="${outputDir}/stdout"
|
||||
@@ -79,11 +66,10 @@ oneTimeSetUp()
|
||||
testDir="${SHUNIT_TMPDIR}/some_test_dir"
|
||||
}
|
||||
|
||||
tearDown()
|
||||
{
|
||||
tearDown() {
|
||||
rm -fr "${testDir}"
|
||||
}
|
||||
|
||||
# load and run shUnit2
|
||||
# Load and run shUnit2.
|
||||
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
||||
. ../src/shunit2
|
||||
. ../shunit2
|
80
.zprezto/modules/prompt/external/powerlevel9k/shunit2/examples/mock_file.sh
vendored
Executable file
80
.zprezto/modules/prompt/external/powerlevel9k/shunit2/examples/mock_file.sh
vendored
Executable file
@@ -0,0 +1,80 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# shUnit2 example for mocking files.
|
||||
#
|
||||
# This example demonstrates two different mechanisms for mocking files on the
|
||||
# system. The first method is preferred for testing specific aspects of a file,
|
||||
# and the second method is preferred when multiple tests need access to the
|
||||
# same mock data.
|
||||
#
|
||||
# When mocking files, the key thing of importance is providing the code under
|
||||
# test with the correct file to read. The best practice for writing code where
|
||||
# files need to be mocked is either:
|
||||
# - Pass the filename to be tested into a function and test that function, or
|
||||
# - Provide a function that returns the name of the filename to be read.
|
||||
#
|
||||
# The first case is preferred whenever possible as it allows the unit test to
|
||||
# be explicit about what is being tested. The second case is useful when the
|
||||
# first case is not achievable.
|
||||
#
|
||||
# For the second case, there are two common methods to mock the filename
|
||||
# returned by the function:
|
||||
# - Provide a special value (e.g. a mock variable) that is only available
|
||||
# during testing, or
|
||||
# - Override something (e.g. the constant) in the test script.
|
||||
#
|
||||
# The first case is preferred as it doesn't require the unit test to alter code
|
||||
# in any way. Yes, it means that the code itself knows that it is under test,
|
||||
# and it behaves slightly differently than under normal conditions, but a
|
||||
# visual inspection of the code by the developer should be sufficient to
|
||||
# validate proper functionality of such a simple function.
|
||||
|
||||
# Treat unset variables as an error.
|
||||
set -u
|
||||
|
||||
PASSWD='/etc/passwd'
|
||||
|
||||
# Read the root UID from the passwd filename provided as the first argument.
|
||||
root_uid_from_passed_filename() {
|
||||
filename=$1
|
||||
root_uid "${filename}"
|
||||
unset filename
|
||||
}
|
||||
|
||||
|
||||
# Read the root UID from the passwd filename derived by call to the
|
||||
# passwd_filename() function.
|
||||
root_uid_from_derived_filename() {
|
||||
root_uid "$(passwd_filename)"
|
||||
}
|
||||
|
||||
passwd_filename() {
|
||||
if [ -n "${MOCK_PASSWD:-}" ]; then
|
||||
echo "${MOCK_PASSWD}" # Mock file for testing.
|
||||
return
|
||||
fi
|
||||
echo "${PASSWD}"
|
||||
}
|
||||
|
||||
|
||||
# Extract the root UID.
|
||||
root_uid() { awk -F: 'u==$1{print $3}' u=root "$1"; }
|
||||
|
||||
|
||||
main() {
|
||||
echo "root_uid_from_passed_filename:"
|
||||
root_uid_from_passed_filename "${PASSWD}"
|
||||
|
||||
echo
|
||||
|
||||
echo "root_uid_from_derived_filename:"
|
||||
root_uid_from_derived_filename
|
||||
}
|
||||
|
||||
|
||||
# Execute main() if this is run in standalone mode (i.e. not in a unit test).
|
||||
ARGV0="$(basename "$0")"
|
||||
argv0="$(echo "${ARGV0}" |sed 's/_test$//;s/_test\.sh$//')"
|
||||
if [ "${ARGV0}" = "${argv0}" ]; then
|
||||
main "$@"
|
||||
fi
|
33
.zprezto/modules/prompt/external/powerlevel9k/shunit2/examples/mock_file_test.sh
vendored
Executable file
33
.zprezto/modules/prompt/external/powerlevel9k/shunit2/examples/mock_file_test.sh
vendored
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# shUnit2 example for mocking files.
|
||||
|
||||
MOCK_PASSWD='' # This will be overridden in oneTimeSetUp().
|
||||
|
||||
test_root_uid_from_passed_filename() {
|
||||
result="$(root_uid_from_passed_filename "${MOCK_PASSWD}")"
|
||||
assertEquals 'unexpected root uid' '0' "${result}"
|
||||
}
|
||||
|
||||
test_root_uid_from_derived_filename() {
|
||||
result="$(root_uid_from_derived_filename)"
|
||||
assertEquals 'unexpected root uid' '0' "${result}"
|
||||
}
|
||||
|
||||
oneTimeSetUp() {
|
||||
# Provide a mock passwd file for testing. This will be cleaned up
|
||||
# automatically by shUnit2.
|
||||
MOCK_PASSWD="${SHUNIT_TMPDIR}/passwd"
|
||||
cat <<EOF >"${MOCK_PASSWD}"
|
||||
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false
|
||||
root:*:0:0:System Administrator:/var/root:/bin/sh
|
||||
daemon:*:1:1:System Services:/var/root:/usr/bin/false
|
||||
EOF
|
||||
|
||||
# Load script under test.
|
||||
. './mock_file.sh'
|
||||
}
|
||||
|
||||
# Load and run shUnit2.
|
||||
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
||||
. ../shunit2
|
16
.zprezto/modules/prompt/external/powerlevel9k/shunit2/examples/party_test.sh
vendored
Executable file
16
.zprezto/modules/prompt/external/powerlevel9k/shunit2/examples/party_test.sh
vendored
Executable file
@@ -0,0 +1,16 @@
|
||||
#! /bin/sh
|
||||
# file: examples/party_test.sh
|
||||
#
|
||||
# This test is mostly for fun. Technically, it is a bad example of a unit test
|
||||
# because of the temporal requirement, namely that the year be 1999. A better
|
||||
# test would have been to pass in both a known-bad and known-good year into a
|
||||
# function, and test for the expected result.
|
||||
|
||||
testPartyLikeItIs1999() {
|
||||
year=`date '+%Y'`
|
||||
assertEquals "It's not 1999 :-(" \
|
||||
'1999' "${year}"
|
||||
}
|
||||
|
||||
# Load and run shUnit2.
|
||||
. ../shunit2
|
32
.zprezto/modules/prompt/external/powerlevel9k/shunit2/examples/suite_test.sh
vendored
Executable file
32
.zprezto/modules/prompt/external/powerlevel9k/shunit2/examples/suite_test.sh
vendored
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# file: examples/suite_test.sh
|
||||
#
|
||||
# This test demonstrates the use of suites. Note: the suite functionality is
|
||||
# deprecated as of v2.1.0, and will be removed in a future major release.
|
||||
|
||||
# suite is a special function called by shUnit2 to setup a suite of tests. It
|
||||
# enables a developer to call a set of functions that contain tests without
|
||||
# needing to rename the functions to start with "test".
|
||||
#
|
||||
# Tests that are to be called from within `suite()` are added to the list of
|
||||
# executable tests by means of the `suite_addTest()` function.
|
||||
suite() {
|
||||
# Add the suite_test_one() function to the list of executable tests.
|
||||
suite_addTest suite_test_one
|
||||
|
||||
# Call the suite_test_two() function, but note that the test results will not
|
||||
# be added to the global stats, and therefore not reported at the end of the
|
||||
# unit test execution.
|
||||
suite_test_two
|
||||
}
|
||||
|
||||
suite_test_one() {
|
||||
assertEquals 1 1
|
||||
}
|
||||
|
||||
suite_test_two() {
|
||||
assertNotEquals 1 2
|
||||
}
|
||||
|
||||
# Load and run shUnit2.
|
||||
. ../shunit2
|
88
.zprezto/modules/prompt/external/powerlevel9k/shunit2/gen_test_report.sh
vendored
Executable file
88
.zprezto/modules/prompt/external/powerlevel9k/shunit2/gen_test_report.sh
vendored
Executable file
@@ -0,0 +1,88 @@
|
||||
#! /bin/sh
|
||||
# vim:et:ft=sh:sts=2:sw=2
|
||||
#
|
||||
# This script runs the provided unit tests and sends the output to the
|
||||
# appropriate file.
|
||||
#
|
||||
# Copyright 2008-2017 Kate Ward. All Rights Reserved.
|
||||
# Released under the Apache 2.0 license.
|
||||
#
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
# https://github.com/kward/shunit2
|
||||
#
|
||||
# Source following.
|
||||
# shellcheck disable=SC1090,SC1091
|
||||
# FLAGS variables are dynamically created.
|
||||
# shellcheck disable=SC2154
|
||||
# Disagree with [ p ] && [ q ] vs [ p -a -q ] recommendation.
|
||||
# shellcheck disable=SC2166
|
||||
|
||||
# Treat unset variables as an error.
|
||||
set -u
|
||||
|
||||
die() {
|
||||
[ $# -gt 0 ] && echo "error: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
BASE_DIR=$(dirname "$0")
|
||||
LIB_DIR="${BASE_DIR}/lib"
|
||||
|
||||
### Load libraries.
|
||||
. "${LIB_DIR}/shflags" || die 'unable to load shflags library'
|
||||
. "${LIB_DIR}/shlib" || die 'unable to load shlib library'
|
||||
. "${LIB_DIR}/versions" || die 'unable to load versions library'
|
||||
|
||||
# Redefining BASE_DIR now that we have the shlib functions. We need BASE_DIR so
|
||||
# that we can properly load things, even in the event that this script is called
|
||||
# from a different directory.
|
||||
BASE_DIR=$(shlib_relToAbsPath "${BASE_DIR}")
|
||||
|
||||
# Define flags.
|
||||
os_name=$(versions_osName |sed 's/ /_/g')
|
||||
os_version=$(versions_osVersion)
|
||||
|
||||
DEFINE_boolean force false 'force overwrite' f
|
||||
DEFINE_string output_dir "${TMPDIR}" 'output dir' d
|
||||
DEFINE_string output_file "${os_name}-${os_version}.txt" 'output file' o
|
||||
DEFINE_string runner 'test_runner' 'unit test runner' r
|
||||
DEFINE_boolean dry_run false "suppress logging to a file" n
|
||||
|
||||
main() {
|
||||
# Determine output filename.
|
||||
# shellcheck disable=SC2154
|
||||
output="${FLAGS_output_dir:+${FLAGS_output_dir}/}${FLAGS_output_file}"
|
||||
output=$(shlib_relToAbsPath "${output}")
|
||||
|
||||
# Checks.
|
||||
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" -a -f "${output}" ]; then
|
||||
if [ "${FLAGS_force}" -eq "${FLAGS_TRUE}" ]; then
|
||||
rm -f "${output}"
|
||||
else
|
||||
echo "not overwriting '${output}'" >&2
|
||||
exit "${FLAGS_ERROR}"
|
||||
fi
|
||||
fi
|
||||
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" ]; then
|
||||
touch "${output}" 2>/dev/null || die "unable to write to '${output}'"
|
||||
fi
|
||||
|
||||
# Run tests.
|
||||
(
|
||||
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" ]; then
|
||||
"./${FLAGS_runner}" |tee "${output}"
|
||||
else
|
||||
"./${FLAGS_runner}"
|
||||
fi
|
||||
)
|
||||
|
||||
if [ "${FLAGS_dry_run}" -eq "${FLAGS_FALSE}" ]; then
|
||||
echo >&2
|
||||
echo "Output written to '${output}'." >&2
|
||||
fi
|
||||
}
|
||||
|
||||
FLAGS "$@" || exit $?
|
||||
[ "${FLAGS_help}" -eq "${FLAGS_FALSE}" ] || exit
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
main "${@:-}"
|
File diff suppressed because it is too large
Load Diff
272
.zprezto/modules/prompt/external/powerlevel9k/shunit2/lib/versions
vendored
Executable file
272
.zprezto/modules/prompt/external/powerlevel9k/shunit2/lib/versions
vendored
Executable file
@@ -0,0 +1,272 @@
|
||||
#! /bin/sh
|
||||
# vim:et:ft=sh:sts=2:sw=2
|
||||
#
|
||||
# Versions determines the versions of all installed shells.
|
||||
#
|
||||
# Copyright 2008-2018 Kate Ward. All Rights Reserved.
|
||||
# Released under the Apache 2.0 License.
|
||||
#
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
# https://github.com/kward/shlib
|
||||
#
|
||||
# This library provides reusable functions that determine actual names and
|
||||
# versions of installed shells and the OS. The library can also be run as a
|
||||
# script if set executable.
|
||||
#
|
||||
# Disable checks that aren't fully portable (POSIX != portable).
|
||||
# shellcheck disable=SC2006
|
||||
|
||||
ARGV0=`basename "$0"`
|
||||
LSB_RELEASE='/etc/lsb-release'
|
||||
VERSIONS_SHELLS='ash /bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/zsh /bin/sh /usr/xpg4/bin/sh /sbin/sh'
|
||||
|
||||
true; TRUE=$?
|
||||
false; FALSE=$?
|
||||
ERROR=2
|
||||
|
||||
UNAME_R=`uname -r`
|
||||
UNAME_S=`uname -s`
|
||||
|
||||
__versions_haveStrings=${ERROR}
|
||||
|
||||
versions_osName() {
|
||||
os_name_='unrecognized'
|
||||
os_system_=${UNAME_S}
|
||||
os_release_=${UNAME_R}
|
||||
case ${os_system_} in
|
||||
CYGWIN_NT-*) os_name_='Cygwin' ;;
|
||||
Darwin)
|
||||
os_name_=`/usr/bin/sw_vers -productName`
|
||||
os_version_=`versions_osVersion`
|
||||
case ${os_version_} in
|
||||
10.4|10.4.[0-9]*) os_name_='Mac OS X Tiger' ;;
|
||||
10.5|10.5.[0-9]*) os_name_='Mac OS X Leopard' ;;
|
||||
10.6|10.6.[0-9]*) os_name_='Mac OS X Snow Leopard' ;;
|
||||
10.7|10.7.[0-9]*) os_name_='Mac OS X Lion' ;;
|
||||
10.8|10.8.[0-9]*) os_name_='Mac OS X Mountain Lion' ;;
|
||||
10.9|10.9.[0-9]*) os_name_='Mac OS X Mavericks' ;;
|
||||
10.10|10.10.[0-9]*) os_name_='Mac OS X Yosemite' ;;
|
||||
10.11|10.11.[0-9]*) os_name_='Mac OS X El Capitan' ;;
|
||||
10.12|10.12.[0-9]*) os_name_='macOS Sierra' ;;
|
||||
10.13|10.13.[0-9]*) os_name_='macOS High Sierra' ;;
|
||||
*) os_name_='macOS' ;;
|
||||
esac
|
||||
;;
|
||||
FreeBSD) os_name_='FreeBSD' ;;
|
||||
Linux) os_name_='Linux' ;;
|
||||
SunOS)
|
||||
os_name_='SunOS'
|
||||
if [ -r '/etc/release' ]; then
|
||||
if grep 'OpenSolaris' /etc/release >/dev/null; then
|
||||
os_name_='OpenSolaris'
|
||||
else
|
||||
os_name_='Solaris'
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
echo ${os_name_}
|
||||
unset os_name_ os_system_ os_release_ os_version_
|
||||
}
|
||||
|
||||
versions_osVersion() {
|
||||
os_version_='unrecognized'
|
||||
os_system_=${UNAME_S}
|
||||
os_release_=${UNAME_R}
|
||||
case ${os_system_} in
|
||||
CYGWIN_NT-*)
|
||||
os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]\.[0-9]*\).*'`
|
||||
;;
|
||||
Darwin)
|
||||
os_version_=`/usr/bin/sw_vers -productVersion`
|
||||
;;
|
||||
FreeBSD)
|
||||
os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]*\)-.*'`
|
||||
;;
|
||||
Linux)
|
||||
if [ -r '/etc/os-release' ]; then
|
||||
os_version_=`awk -F= '$1~/PRETTY_NAME/{print $2}' /etc/os-release \
|
||||
|sed 's/"//g'`
|
||||
elif [ -r '/etc/redhat-release' ]; then
|
||||
os_version_=`cat /etc/redhat-release`
|
||||
elif [ -r '/etc/SuSE-release' ]; then
|
||||
os_version_=`head -n 1 /etc/SuSE-release`
|
||||
elif [ -r "${LSB_RELEASE}" ]; then
|
||||
if grep -q 'DISTRIB_ID=Ubuntu' "${LSB_RELEASE}"; then
|
||||
# shellcheck disable=SC2002
|
||||
os_version_=`cat "${LSB_RELEASE}" \
|
||||
|awk -F= '$1~/DISTRIB_DESCRIPTION/{print $2}' \
|
||||
|sed 's/"//g;s/ /-/g'`
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
SunOS)
|
||||
if [ -r '/etc/release' ]; then
|
||||
if grep 'OpenSolaris' /etc/release >/dev/null; then # OpenSolaris
|
||||
os_version_=`grep 'OpenSolaris' /etc/release |awk '{print $2"("$3")"}'`
|
||||
else # Solaris
|
||||
major_=`echo "${os_release_}" |sed 's/[0-9]*\.\([0-9]*\)/\1/'`
|
||||
minor_=`grep Solaris /etc/release |sed 's/[^u]*\(u[0-9]*\).*/\1/'`
|
||||
os_version_="${major_}${minor_}"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "${os_version_}"
|
||||
unset os_release_ os_system_ os_version_ major_ minor_
|
||||
}
|
||||
|
||||
versions_shellVersion() {
|
||||
shell_=$1
|
||||
|
||||
shell_present_=${FALSE}
|
||||
case "${shell_}" in
|
||||
ash) [ -x '/bin/busybox' ] && shell_present_=${TRUE} ;;
|
||||
*) [ -x "${shell_}" ] && shell_present_=${TRUE} ;;
|
||||
esac
|
||||
if [ ${shell_present_} -eq ${FALSE} ]; then
|
||||
echo 'not installed'
|
||||
return ${FALSE}
|
||||
fi
|
||||
|
||||
version_=''
|
||||
case ${shell_} in
|
||||
/sbin/sh) ;; # SunOS
|
||||
/usr/xpg4/bin/sh)
|
||||
version_=`versions_shell_xpg4 "${shell_}"`
|
||||
;; # SunOS
|
||||
*/sh)
|
||||
# This could be one of any number of shells. Try until one fits.
|
||||
version_=''
|
||||
[ -z "${version_}" ] && version_=`versions_shell_bash "${shell_}"`
|
||||
# dash cannot be self determined yet
|
||||
[ -z "${version_}" ] && version_=`versions_shell_ksh "${shell_}"`
|
||||
# pdksh is covered in versions_shell_ksh()
|
||||
[ -z "${version_}" ] && version_=`versions_shell_xpg4 "${shell_}"`
|
||||
[ -z "${version_}" ] && version_=`versions_shell_zsh "${shell_}"`
|
||||
;;
|
||||
ash) version_=`versions_shell_ash "${shell_}"` ;;
|
||||
*/bash) version_=`versions_shell_bash "${shell_}"` ;;
|
||||
*/dash)
|
||||
# Assuming Ubuntu Linux until somebody comes up with a better test. The
|
||||
# following test will return an empty string if dash is not installed.
|
||||
version_=`versions_shell_dash`
|
||||
;;
|
||||
*/ksh) version_=`versions_shell_ksh "${shell_}"` ;;
|
||||
*/pdksh) version_=`versions_shell_pdksh "${shell_}"` ;;
|
||||
*/zsh) version_=`versions_shell_zsh "${shell_}"` ;;
|
||||
*) version_='invalid'
|
||||
esac
|
||||
|
||||
echo "${version_:-unknown}"
|
||||
unset shell_ version_
|
||||
}
|
||||
|
||||
# The ash shell is included in BusyBox.
|
||||
versions_shell_ash() {
|
||||
busybox --help |head -1 |sed 's/BusyBox v\([0-9.]*\) .*/\1/'
|
||||
}
|
||||
|
||||
versions_shell_bash() {
|
||||
$1 --version : 2>&1 |grep 'GNU bash' |sed 's/.*version \([^ ]*\).*/\1/'
|
||||
}
|
||||
|
||||
versions_shell_dash() {
|
||||
eval dpkg >/dev/null 2>&1
|
||||
[ $? -eq 127 ] && return # Return if dpkg not found.
|
||||
|
||||
dpkg -l |grep ' dash ' |awk '{print $3}'
|
||||
}
|
||||
|
||||
versions_shell_ksh() {
|
||||
versions_shell_=$1
|
||||
versions_version_=''
|
||||
|
||||
# Try a few different ways to figure out the version.
|
||||
versions_version_=`${versions_shell_} --version : 2>&1`
|
||||
# shellcheck disable=SC2181
|
||||
if [ $? -eq 0 ]; then
|
||||
versions_version_=`echo "${versions_version_}" \
|
||||
|sed 's/.*\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\).*/\1/'`
|
||||
else
|
||||
versions_version_=''
|
||||
fi
|
||||
if [ -z "${versions_version_}" ]; then
|
||||
_versions_have_strings
|
||||
versions_version_=`strings "${versions_shell_}" 2>&1 \
|
||||
|grep Version \
|
||||
|sed 's/^.*Version \(.*\)$/\1/;s/ s+ \$$//;s/ /-/g'`
|
||||
fi
|
||||
if [ -z "${versions_version_}" ]; then
|
||||
versions_version_=`versions_shell_pdksh "${versions_shell_}"`
|
||||
fi
|
||||
|
||||
echo "${versions_version_}"
|
||||
unset versions_shell_ versions_version_
|
||||
}
|
||||
|
||||
versions_shell_pdksh() {
|
||||
_versions_have_strings
|
||||
strings "$1" 2>&1 \
|
||||
|grep 'PD KSH' \
|
||||
|sed -e 's/.*PD KSH \(.*\)/\1/;s/ /-/g'
|
||||
}
|
||||
|
||||
versions_shell_xpg4() {
|
||||
_versions_have_strings
|
||||
strings "$1" 2>&1 \
|
||||
|grep 'Version' \
|
||||
|sed -e 's/^@(#)Version //'
|
||||
}
|
||||
|
||||
versions_shell_zsh() {
|
||||
versions_shell_=$1
|
||||
|
||||
# Try a few different ways to figure out the version.
|
||||
# shellcheck disable=SC2016
|
||||
versions_version_=`echo 'echo ${ZSH_VERSION}' |${versions_shell_}`
|
||||
if [ -z "${versions_version_}" ]; then
|
||||
versions_version_=`${versions_shell_} --version : 2>&1`
|
||||
# shellcheck disable=SC2181
|
||||
if [ $? -eq 0 ]; then
|
||||
versions_version_=`echo "${versions_version_}" |awk '{print $2}'`
|
||||
else
|
||||
versions_version_=''
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${versions_version_}"
|
||||
unset versions_shell_ versions_version_
|
||||
}
|
||||
|
||||
# Determine if the 'strings' binary installed.
|
||||
_versions_have_strings() {
|
||||
[ ${__versions_haveStrings} -ne ${ERROR} ] && return
|
||||
if eval strings /dev/null >/dev/null 2>&1; then
|
||||
__versions_haveStrings=${TRUE}
|
||||
return
|
||||
fi
|
||||
|
||||
echo 'WARN: strings not installed. try installing binutils?' >&2
|
||||
__versions_haveStrings=${FALSE}
|
||||
}
|
||||
|
||||
versions_main() {
|
||||
# Treat unset variables as an error.
|
||||
set -u
|
||||
|
||||
os_name=`versions_osName`
|
||||
os_version=`versions_osVersion`
|
||||
echo "os: ${os_name} version: ${os_version}"
|
||||
|
||||
for shell in ${VERSIONS_SHELLS}; do
|
||||
shell_version=`versions_shellVersion "${shell}"`
|
||||
echo "shell: ${shell} version: ${shell_version}"
|
||||
done
|
||||
}
|
||||
|
||||
if [ "${ARGV0}" = 'versions' ]; then
|
||||
versions_main "$@"
|
||||
fi
|
File diff suppressed because it is too large
Load Diff
@@ -1,23 +1,25 @@
|
||||
#! /bin/sh
|
||||
# $Id$
|
||||
# vim:et:ft=sh:sts=2:sw=2
|
||||
#
|
||||
# Copyright 2008 Kate Ward. All Rights Reserved.
|
||||
# Released under the LGPL (GNU Lesser General Public License)
|
||||
# shunit2 unit test for assert functions.
|
||||
#
|
||||
# Copyright 2008-2017 Kate Ward. All Rights Reserved.
|
||||
# Released under the Apache 2.0 license.
|
||||
#
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
# https://github.com/kward/shunit2
|
||||
#
|
||||
# shUnit2 unit test for assert functions
|
||||
# Disable source following.
|
||||
# shellcheck disable=SC1090,SC1091
|
||||
|
||||
# load test helpers
|
||||
# These variables will be overridden by the test helpers.
|
||||
stdoutF="${TMPDIR:-/tmp}/STDOUT"
|
||||
stderrF="${TMPDIR:-/tmp}/STDERR"
|
||||
|
||||
# Load test helpers.
|
||||
. ./shunit2_test_helpers
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# suite tests
|
||||
#
|
||||
|
||||
commonEqualsSame()
|
||||
{
|
||||
commonEqualsSame() {
|
||||
fn=$1
|
||||
|
||||
( ${fn} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||
@@ -42,8 +44,7 @@ commonEqualsSame()
|
||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
||||
}
|
||||
|
||||
commonNotEqualsSame()
|
||||
{
|
||||
commonNotEqualsSame() {
|
||||
fn=$1
|
||||
|
||||
( ${fn} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||
@@ -65,28 +66,23 @@ commonNotEqualsSame()
|
||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
||||
}
|
||||
|
||||
testAssertEquals()
|
||||
{
|
||||
testAssertEquals() {
|
||||
commonEqualsSame 'assertEquals'
|
||||
}
|
||||
|
||||
testAssertNotEquals()
|
||||
{
|
||||
testAssertNotEquals() {
|
||||
commonNotEqualsSame 'assertNotEquals'
|
||||
}
|
||||
|
||||
testAssertSame()
|
||||
{
|
||||
testAssertSame() {
|
||||
commonEqualsSame 'assertSame'
|
||||
}
|
||||
|
||||
testAssertNotSame()
|
||||
{
|
||||
testAssertNotSame() {
|
||||
commonNotEqualsSame 'assertNotSame'
|
||||
}
|
||||
|
||||
testAssertNull()
|
||||
{
|
||||
testAssertNull() {
|
||||
( assertNull '' >"${stdoutF}" 2>"${stderrF}" )
|
||||
th_assertTrueWithNoOutput 'null' $? "${stdoutF}" "${stderrF}"
|
||||
|
||||
@@ -119,6 +115,7 @@ testAssertNotNull()
|
||||
th_assertTrueWithNoOutput 'not null, with single-quote' $? \
|
||||
"${stdoutF}" "${stderrF}"
|
||||
|
||||
# shellcheck disable=SC2016
|
||||
( assertNotNull 'x$b' >"${stdoutF}" 2>"${stderrF}" )
|
||||
th_assertTrueWithNoOutput 'not null, with dollar' $? \
|
||||
"${stdoutF}" "${stderrF}"
|
||||
@@ -130,14 +127,13 @@ testAssertNotNull()
|
||||
( assertNotNull '' >"${stdoutF}" 2>"${stderrF}" )
|
||||
th_assertFalseWithOutput 'null' $? "${stdoutF}" "${stderrF}"
|
||||
|
||||
# there is no test for too few arguments as $1 might actually be null
|
||||
# There is no test for too few arguments as $1 might actually be null.
|
||||
|
||||
( assertNotNull arg1 arg2 arg3 >"${stdoutF}" 2>"${stderrF}" )
|
||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
||||
}
|
||||
|
||||
testAssertTrue()
|
||||
{
|
||||
testAssertTrue() {
|
||||
( assertTrue 0 >"${stdoutF}" 2>"${stderrF}" )
|
||||
th_assertTrueWithNoOutput 'true' $? "${stdoutF}" "${stderrF}"
|
||||
|
||||
@@ -163,8 +159,7 @@ testAssertTrue()
|
||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
||||
}
|
||||
|
||||
testAssertFalse()
|
||||
{
|
||||
testAssertFalse() {
|
||||
( assertFalse 1 >"${stdoutF}" 2>"${stderrF}" )
|
||||
th_assertTrueWithNoOutput 'false' $? "${stdoutF}" "${stderrF}"
|
||||
|
||||
@@ -190,17 +185,13 @@ testAssertFalse()
|
||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# suite functions
|
||||
#
|
||||
|
||||
oneTimeSetUp()
|
||||
{
|
||||
oneTimeSetUp() {
|
||||
th_oneTimeSetUp
|
||||
|
||||
MSG='This is a test message'
|
||||
}
|
||||
|
||||
# load and run shUnit2
|
||||
# Load and run shunit2.
|
||||
# shellcheck disable=SC2034
|
||||
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
||||
. ${TH_SHUNIT}
|
||||
. "${TH_SHUNIT}"
|
@@ -1,23 +1,25 @@
|
||||
#! /bin/sh
|
||||
# $Id$
|
||||
# vim:et:ft=sh:sts=2:sw=2
|
||||
#
|
||||
# Copyright 2008 Kate Ward. All Rights Reserved.
|
||||
# shUnit2 unit test for failure functions
|
||||
#
|
||||
# Copyright 2008-2017 Kate Ward. All Rights Reserved.
|
||||
# Released under the LGPL (GNU Lesser General Public License)
|
||||
#
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
# https://github.com/kward/shunit2
|
||||
#
|
||||
# shUnit2 unit test for failure functions
|
||||
# Disable source following.
|
||||
# shellcheck disable=SC1090,SC1091
|
||||
|
||||
# load common unit-test functions
|
||||
# These variables will be overridden by the test helpers.
|
||||
stdoutF="${TMPDIR:-/tmp}/STDOUT"
|
||||
stderrF="${TMPDIR:-/tmp}/STDERR"
|
||||
|
||||
# Load test helpers.
|
||||
. ./shunit2_test_helpers
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite tests
|
||||
#
|
||||
|
||||
testFail()
|
||||
{
|
||||
testFail() {
|
||||
( fail >"${stdoutF}" 2>"${stderrF}" )
|
||||
th_assertFalseWithOutput 'fail' $? "${stdoutF}" "${stderrF}"
|
||||
|
||||
@@ -28,8 +30,7 @@ testFail()
|
||||
th_assertFalseWithOutput 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
||||
}
|
||||
|
||||
testFailNotEquals()
|
||||
{
|
||||
testFailNotEquals() {
|
||||
( failNotEquals 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||
th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}"
|
||||
|
||||
@@ -49,8 +50,7 @@ testFailNotEquals()
|
||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
||||
}
|
||||
|
||||
testFailSame()
|
||||
{
|
||||
testFailSame() {
|
||||
( failSame 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||
th_assertFalseWithOutput 'same' $? "${stdoutF}" "${stderrF}"
|
||||
|
||||
@@ -70,17 +70,13 @@ testFailSame()
|
||||
th_assertFalseWithError 'too many arguments' $? "${stdoutF}" "${stderrF}"
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite functions
|
||||
#
|
||||
|
||||
oneTimeSetUp()
|
||||
{
|
||||
oneTimeSetUp() {
|
||||
th_oneTimeSetUp
|
||||
|
||||
MSG='This is a test message'
|
||||
}
|
||||
|
||||
# load and run shUnit2
|
||||
# Load and run shUnit2.
|
||||
# shellcheck disable=SC2034
|
||||
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
||||
. ${TH_SHUNIT}
|
||||
. "${TH_SHUNIT}"
|
@@ -1,108 +1,110 @@
|
||||
#! /bin/sh
|
||||
# $Id$
|
||||
# vim:et:ft=sh:sts=2:sw=2
|
||||
#
|
||||
# Copyright 2008 Kate Ward. All Rights Reserved.
|
||||
# Released under the LGPL (GNU Lesser General Public License)
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
# shunit2 unit test for macros.
|
||||
#
|
||||
# shUnit2 unit test for macros.
|
||||
# Copyright 2008-2017 Kate Ward. All Rights Reserved.
|
||||
# Released under the Apache 2.0 license.
|
||||
#
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
# https://github.com/kward/shunit2
|
||||
#
|
||||
### ShellCheck http://www.shellcheck.net/
|
||||
# Disable source following.
|
||||
# shellcheck disable=SC1090,SC1091
|
||||
# Presence of LINENO variable is checked.
|
||||
# shellcheck disable=SC2039
|
||||
|
||||
# load test helpers
|
||||
# These variables will be overridden by the test helpers.
|
||||
stdoutF="${TMPDIR:-/tmp}/STDOUT"
|
||||
stderrF="${TMPDIR:-/tmp}/STDERR"
|
||||
|
||||
# Load test helpers.
|
||||
. ./shunit2_test_helpers
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# suite tests
|
||||
#
|
||||
|
||||
testAssertEquals()
|
||||
{
|
||||
# start skipping if LINENO not available
|
||||
testAssertEquals() {
|
||||
# Start skipping if LINENO not available.
|
||||
[ -z "${LINENO:-}" ] && startSkipping
|
||||
|
||||
( ${_ASSERT_EQUALS_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_EQUALS_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
( ${_ASSERT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_EQUALS_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
testAssertNotEquals()
|
||||
{
|
||||
# start skipping if LINENO not available
|
||||
testAssertNotEquals() {
|
||||
# Start skipping if LINENO not available.
|
||||
[ -z "${LINENO:-}" ] && startSkipping
|
||||
|
||||
( ${_ASSERT_NOT_EQUALS_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_NOT_EQUALS_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
( ${_ASSERT_NOT_EQUALS_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_NOT_EQUALS_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
testSame()
|
||||
{
|
||||
# start skipping if LINENO not available
|
||||
testSame() {
|
||||
# Start skipping if LINENO not available.
|
||||
[ -z "${LINENO:-}" ] && startSkipping
|
||||
|
||||
( ${_ASSERT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_SAME_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
( ${_ASSERT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_SAME_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
testNotSame()
|
||||
{
|
||||
# start skipping if LINENO not available
|
||||
testNotSame() {
|
||||
# Start skipping if LINENO not available.
|
||||
[ -z "${LINENO:-}" ] && startSkipping
|
||||
|
||||
( ${_ASSERT_NOT_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_NOT_SAME_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
( ${_ASSERT_NOT_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_NOT_SAME_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
testNull()
|
||||
{
|
||||
# start skipping if LINENO not available
|
||||
testNull() {
|
||||
# Start skipping if LINENO not available.
|
||||
[ -z "${LINENO:-}" ] && startSkipping
|
||||
|
||||
( ${_ASSERT_NULL_} 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_NULL_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
( ${_ASSERT_NULL_} '"some msg"' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_NULL_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
testNotNull()
|
||||
@@ -114,68 +116,64 @@ testNotNull()
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_NOT_NULL_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
( ${_ASSERT_NOT_NULL_} '"some msg"' '""' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_NOT_NULL_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stdoutF}" "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stdoutF}" "${stderrF}" >&2
|
||||
}
|
||||
|
||||
testAssertTrue()
|
||||
{
|
||||
# start skipping if LINENO not available
|
||||
testAssertTrue() {
|
||||
# Start skipping if LINENO not available.
|
||||
[ -z "${LINENO:-}" ] && startSkipping
|
||||
|
||||
( ${_ASSERT_TRUE_} ${SHUNIT_FALSE} >"${stdoutF}" 2>"${stderrF}" )
|
||||
( ${_ASSERT_TRUE_} "${SHUNIT_FALSE}" >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_TRUE_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
|
||||
( ${_ASSERT_TRUE_} '"some msg"' ${SHUNIT_FALSE} >"${stdoutF}" 2>"${stderrF}" )
|
||||
( ${_ASSERT_TRUE_} '"some msg"' "${SHUNIT_FALSE}" >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_TRUE_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
testAssertFalse()
|
||||
{
|
||||
# start skipping if LINENO not available
|
||||
testAssertFalse() {
|
||||
# Start skipping if LINENO not available.
|
||||
[ -z "${LINENO:-}" ] && startSkipping
|
||||
|
||||
( ${_ASSERT_FALSE_} ${SHUNIT_TRUE} >"${stdoutF}" 2>"${stderrF}" )
|
||||
( ${_ASSERT_FALSE_} "${SHUNIT_TRUE}" >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_FALSE_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
( ${_ASSERT_FALSE_} '"some msg"' ${SHUNIT_TRUE} >"${stdoutF}" 2>"${stderrF}" )
|
||||
( ${_ASSERT_FALSE_} '"some msg"' "${SHUNIT_TRUE}" >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_ASSERT_FALSE_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
testFail()
|
||||
{
|
||||
# start skipping if LINENO not available
|
||||
testFail() {
|
||||
# Start skipping if LINENO not available.
|
||||
[ -z "${LINENO:-}" ] && startSkipping
|
||||
|
||||
( ${_FAIL_} >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_FAIL_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
( ${_FAIL_} '"some msg"' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_FAIL_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
testFailNotEquals()
|
||||
@@ -187,60 +185,57 @@ testFailNotEquals()
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_FAIL_NOT_EQUALS_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
( ${_FAIL_NOT_EQUALS_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_FAIL_NOT_EQUALS_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
testFailSame()
|
||||
{
|
||||
# start skipping if LINENO not available
|
||||
testFailSame() {
|
||||
# Start skipping if LINENO not available.
|
||||
[ -z "${LINENO:-}" ] && startSkipping
|
||||
|
||||
( ${_FAIL_SAME_} 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_FAIL_SAME_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
( ${_FAIL_SAME_} '"some msg"' 'x' 'x' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_FAIL_SAME_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
testFailNotSame()
|
||||
{
|
||||
# start skipping if LINENO not available
|
||||
testFailNotSame() {
|
||||
# Start skipping if LINENO not available.
|
||||
[ -z "${LINENO:-}" ] && startSkipping
|
||||
|
||||
( ${_FAIL_NOT_SAME_} 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_FAIL_NOT_SAME_ failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
|
||||
( ${_FAIL_NOT_SAME_} '"some msg"' 'x' 'y' >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^ASSERT:\[[0-9]*\] *' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertTrue '_FAIL_NOT_SAME_ w/ msg failure' ${rtrn}
|
||||
[ ${rtrn} -ne ${SHUNIT_TRUE} ] && cat "${stderrF}" >&2
|
||||
[ "${rtrn}" -ne "${SHUNIT_TRUE}" ] && cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# suite functions
|
||||
#
|
||||
|
||||
oneTimeSetUp()
|
||||
{
|
||||
oneTimeSetUp() {
|
||||
th_oneTimeSetUp
|
||||
}
|
||||
|
||||
# load and run shUnit2
|
||||
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
||||
. ${TH_SHUNIT}
|
||||
# Disable output coloring as it breaks the tests.
|
||||
SHUNIT_COLOR='none'; export SHUNIT_COLOR
|
||||
|
||||
# Load and run shUnit2.
|
||||
# shellcheck disable=SC2034
|
||||
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT="$0"
|
||||
. "${TH_SHUNIT}"
|
262
.zprezto/modules/prompt/external/powerlevel9k/shunit2/shunit2_misc_test.sh
vendored
Executable file
262
.zprezto/modules/prompt/external/powerlevel9k/shunit2/shunit2_misc_test.sh
vendored
Executable file
@@ -0,0 +1,262 @@
|
||||
#! /bin/sh
|
||||
# vim:et:ft=sh:sts=2:sw=2
|
||||
#
|
||||
# shUnit2 unit tests of miscellaneous things
|
||||
#
|
||||
# Copyright 2008-2018 Kate Ward. All Rights Reserved.
|
||||
# Released under the Apache 2.0 license.
|
||||
#
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
# https://github.com/kward/shunit2
|
||||
#
|
||||
### ShellCheck http://www.shellcheck.net/
|
||||
# $() are not fully portable (POSIX != portable).
|
||||
# shellcheck disable=SC2006
|
||||
# Disable source following.
|
||||
# shellcheck disable=SC1090,SC1091
|
||||
# Not wanting to escape single quotes.
|
||||
# shellcheck disable=SC1003
|
||||
|
||||
# These variables will be overridden by the test helpers.
|
||||
stdoutF="${TMPDIR:-/tmp}/STDOUT"
|
||||
stderrF="${TMPDIR:-/tmp}/STDERR"
|
||||
|
||||
# Load test helpers.
|
||||
. ./shunit2_test_helpers
|
||||
|
||||
# Note: the test script is prefixed with '#' chars so that shUnit2 does not
|
||||
# incorrectly interpret the embedded functions as real functions.
|
||||
testUnboundVariable() {
|
||||
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||
sed 's/^#//' >"${unittestF}" <<EOF
|
||||
## Treat unset variables as an error when performing parameter expansion.
|
||||
#set -u
|
||||
#
|
||||
#boom() { x=\$1; } # This function goes boom if no parameters are passed!
|
||||
#test_boom() {
|
||||
# assertEquals 1 1
|
||||
# boom # No parameter given
|
||||
# assertEquals 0 \$?
|
||||
#}
|
||||
#SHUNIT_COLOR='none'
|
||||
#. ${TH_SHUNIT}
|
||||
EOF
|
||||
( exec "${SHUNIT_SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" )
|
||||
assertFalse 'expected a non-zero exit value' $?
|
||||
grep '^ASSERT:Unknown failure' "${stdoutF}" >/dev/null
|
||||
assertTrue 'assert message was not generated' $?
|
||||
grep '^Ran [0-9]* test' "${stdoutF}" >/dev/null
|
||||
assertTrue 'test count message was not generated' $?
|
||||
grep '^FAILED' "${stdoutF}" >/dev/null
|
||||
assertTrue 'failure message was not generated' $?
|
||||
}
|
||||
|
||||
# assertEquals repeats message argument.
|
||||
# https://github.com/kward/shunit2/issues/7
|
||||
testIssue7() {
|
||||
# Disable coloring so 'ASSERT:' lines can be matched correctly.
|
||||
_shunit_configureColor 'none'
|
||||
|
||||
( assertEquals 'Some message.' 1 2 >"${stdoutF}" 2>"${stderrF}" )
|
||||
diff "${stdoutF}" - >/dev/null <<EOF
|
||||
ASSERT:Some message. expected:<1> but was:<2>
|
||||
EOF
|
||||
rtrn=$?
|
||||
assertEquals "${SHUNIT_TRUE}" "${rtrn}"
|
||||
[ "${rtrn}" -eq "${SHUNIT_TRUE}" ] || cat "${stderrF}" >&2
|
||||
}
|
||||
|
||||
# Support prefixes on test output.
|
||||
# https://github.com/kward/shunit2/issues/29
|
||||
testIssue29() {
|
||||
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||
sed 's/^#//' >"${unittestF}" <<EOF
|
||||
## Support test prefixes.
|
||||
#test_assert() { assertTrue ${SHUNIT_TRUE}; }
|
||||
#SHUNIT_COLOR='none'
|
||||
#SHUNIT_TEST_PREFIX='--- '
|
||||
#. ${TH_SHUNIT}
|
||||
EOF
|
||||
( exec "${SHUNIT_SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^--- test_assert' "${stdoutF}" >/dev/null
|
||||
rtrn=$?
|
||||
assertEquals "${SHUNIT_TRUE}" "${rtrn}"
|
||||
[ "${rtrn}" -eq "${SHUNIT_TRUE}" ] || cat "${stdoutF}" >&2
|
||||
}
|
||||
|
||||
# shUnit2 should not exit with 0 when it has syntax errors.
|
||||
# https://github.com/kward/shunit2/issues/69
|
||||
testIssue69() {
|
||||
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||
|
||||
for t in Equals NotEquals Null NotNull Same NotSame True False; do
|
||||
assert="assert${t}"
|
||||
sed 's/^#//' >"${unittestF}" <<EOF
|
||||
## Asserts with invalid argument counts should be counted as failures.
|
||||
#test_assert() { ${assert}; }
|
||||
#SHUNIT_COLOR='none'
|
||||
#. ${TH_SHUNIT}
|
||||
EOF
|
||||
( exec "${SHUNIT_SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^FAILED' "${stdoutF}" >/dev/null
|
||||
assertTrue "failure message for ${assert} was not generated" $?
|
||||
done
|
||||
}
|
||||
|
||||
# Ensure that test fails if setup/teardown functions fail.
|
||||
testIssue77() {
|
||||
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||
for func in oneTimeSetUp setUp tearDown oneTimeTearDown; do
|
||||
sed 's/^#//' >"${unittestF}" <<EOF
|
||||
## Environment failure should end test.
|
||||
#${func}() { return ${SHUNIT_FALSE}; }
|
||||
#test_true() { assertTrue ${SHUNIT_TRUE}; }
|
||||
#SHUNIT_COLOR='none'
|
||||
#. ${TH_SHUNIT}
|
||||
EOF
|
||||
( exec "${SHUNIT_SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^FAILED' "${stdoutF}" >/dev/null
|
||||
assertTrue "failure of ${func}() did not end test" $?
|
||||
done
|
||||
}
|
||||
|
||||
# Ensure a test failure is recorded for code containing syntax errors.
|
||||
# https://github.com/kward/shunit2/issues/84
|
||||
testIssue84() {
|
||||
unittestF="${SHUNIT_TMPDIR}/unittest"
|
||||
sed 's/^#//' >"${unittestF}" <<\EOF
|
||||
## Function with syntax error.
|
||||
#syntax_error() { ${!#3442} -334 a$@2[1]; }
|
||||
#test_syntax_error() {
|
||||
# syntax_error
|
||||
# assertTrue ${SHUNIT_TRUE}
|
||||
#}
|
||||
#SHUNIT_COLOR='none'
|
||||
#SHUNIT_TEST_PREFIX='--- '
|
||||
#. ${TH_SHUNIT}
|
||||
EOF
|
||||
( exec "${SHUNIT_SHELL:-sh}" "${unittestF}" >"${stdoutF}" 2>"${stderrF}" )
|
||||
grep '^FAILED' "${stdoutF}" >/dev/null
|
||||
assertTrue "failure message for ${assert} was not generated" $?
|
||||
}
|
||||
|
||||
testPrepForSourcing() {
|
||||
assertEquals '/abc' "`_shunit_prepForSourcing '/abc'`"
|
||||
assertEquals './abc' "`_shunit_prepForSourcing './abc'`"
|
||||
assertEquals './abc' "`_shunit_prepForSourcing 'abc'`"
|
||||
}
|
||||
|
||||
testEscapeCharInStr() {
|
||||
while read -r desc char str want; do
|
||||
got=`_shunit_escapeCharInStr "${char}" "${str}"`
|
||||
assertEquals "${desc}" "${want}" "${got}"
|
||||
done <<'EOF'
|
||||
backslash \ '' ''
|
||||
backslash_pre \ \def \\def
|
||||
backslash_mid \ abc\def abc\\def
|
||||
backslash_post \ abc\ abc\\
|
||||
quote " '' ''
|
||||
quote_pre " "def \"def
|
||||
quote_mid " abc"def abc\"def
|
||||
quote_post " abc" abc\"
|
||||
string $ '' ''
|
||||
string_pre $ $def \$def
|
||||
string_mid $ abc$def abc\$def
|
||||
string_post $ abc$ abc\$
|
||||
EOF
|
||||
|
||||
# TODO(20170924:kward) fix or remove.
|
||||
# actual=`_shunit_escapeCharInStr "'" ''`
|
||||
# assertEquals '' "${actual}"
|
||||
# assertEquals "abc\\'" `_shunit_escapeCharInStr "'" "abc'"`
|
||||
# assertEquals "abc\\'def" `_shunit_escapeCharInStr "'" "abc'def"`
|
||||
# assertEquals "\\'def" `_shunit_escapeCharInStr "'" "'def"`
|
||||
|
||||
# # Must put the backtick in a variable so the shell doesn't misinterpret it
|
||||
# # while inside a backticked sequence (e.g. `echo '`'` would fail).
|
||||
# backtick='`'
|
||||
# actual=`_shunit_escapeCharInStr ${backtick} ''`
|
||||
# assertEquals '' "${actual}"
|
||||
# assertEquals '\`abc' \
|
||||
# `_shunit_escapeCharInStr "${backtick}" ${backtick}'abc'`
|
||||
# assertEquals 'abc\`' \
|
||||
# `_shunit_escapeCharInStr "${backtick}" 'abc'${backtick}`
|
||||
# assertEquals 'abc\`def' \
|
||||
# `_shunit_escapeCharInStr "${backtick}" 'abc'${backtick}'def'`
|
||||
}
|
||||
|
||||
testEscapeCharInStr_specialChars() {
|
||||
# Make sure our forward slash doesn't upset sed.
|
||||
assertEquals '/' "`_shunit_escapeCharInStr '\' '/'`"
|
||||
|
||||
# Some shells escape these differently.
|
||||
# TODO(20170924:kward) fix or remove.
|
||||
#assertEquals '\\a' `_shunit_escapeCharInStr '\' '\a'`
|
||||
#assertEquals '\\b' `_shunit_escapeCharInStr '\' '\b'`
|
||||
}
|
||||
|
||||
# Test the various ways of declaring functions.
|
||||
#
|
||||
# Prefixing (then stripping) with comment symbol so these functions aren't
|
||||
# treated as real functions by shUnit2.
|
||||
testExtractTestFunctions() {
|
||||
f="${SHUNIT_TMPDIR}/extract_test_functions"
|
||||
sed 's/^#//' <<EOF >"${f}"
|
||||
## Function on a single line.
|
||||
#testABC() { echo 'ABC'; }
|
||||
## Multi-line function with '{' on next line.
|
||||
#test_def()
|
||||
# {
|
||||
# echo 'def'
|
||||
#}
|
||||
## Multi-line function with '{' on first line.
|
||||
#testG3 () {
|
||||
# echo 'G3'
|
||||
#}
|
||||
## Function with numerical values in name.
|
||||
#function test4() { echo '4'; }
|
||||
## Leading space in front of function.
|
||||
# test5() { echo '5'; }
|
||||
## Function with '_' chars in name.
|
||||
#some_test_function() { echo 'some func'; }
|
||||
## Function that sets variables.
|
||||
#func_with_test_vars() {
|
||||
# testVariable=1234
|
||||
#}
|
||||
EOF
|
||||
|
||||
actual=`_shunit_extractTestFunctions "${f}"`
|
||||
assertEquals 'testABC test_def testG3 test4 test5' "${actual}"
|
||||
}
|
||||
|
||||
# Test that certain external commands sometimes "stubbed" by users
|
||||
# are escaped. See Issue #54.
|
||||
testProtectedCommands() {
|
||||
for c in mkdir rm cat chmod; do
|
||||
grep "^[^#]*${c} " "${TH_SHUNIT}" | grep -qv "command ${c}"
|
||||
assertFalse "external call to ${c} not protected somewhere" $?
|
||||
done
|
||||
grep '^[^#]*[^ ] *\[' "${TH_SHUNIT}" | grep -qv 'command \['
|
||||
assertFalse "call to [ ... ] not protected somewhere" $?
|
||||
grep '^[^#]* *\.' "${TH_SHUNIT}" | grep -qv 'command \.'
|
||||
assertFalse "call to . not protected somewhere" $?
|
||||
}
|
||||
|
||||
setUp() {
|
||||
for f in "${stdoutF}" "${stderrF}"; do
|
||||
cp /dev/null "${f}"
|
||||
done
|
||||
|
||||
# Reconfigure coloring as some tests override default behavior.
|
||||
_shunit_configureColor "${SHUNIT_COLOR_DEFAULT}"
|
||||
}
|
||||
|
||||
oneTimeSetUp() {
|
||||
SHUNIT_COLOR_DEFAULT="${SHUNIT_COLOR}"
|
||||
th_oneTimeSetUp
|
||||
}
|
||||
|
||||
# Load and run shUnit2.
|
||||
# shellcheck disable=SC2034
|
||||
[ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0
|
||||
. "${TH_SHUNIT}"
|
@@ -1,41 +1,38 @@
|
||||
#! /bin/sh
|
||||
# $Id$
|
||||
# vim:et:ft=sh:sts=2:sw=2
|
||||
#
|
||||
# Copyright 2010 Kate Ward. All Rights Reserved.
|
||||
# Released under the LGPL (GNU Lesser General Public License)
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
#
|
||||
# shUnit2 unit test for standalone operation.
|
||||
#
|
||||
# Copyright 2010-2017 Kate Ward. All Rights Reserved.
|
||||
# Released under the Apache 2.0 license.
|
||||
#
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
# https://github.com/kward/shunit2
|
||||
#
|
||||
# This unit test is purely to test that calling shunit2 directly, while passing
|
||||
# the name of a unit test script, works. When run, this script determines if it
|
||||
# is running as a standalone program, and calls main() if it is.
|
||||
#
|
||||
### ShellCheck http://www.shellcheck.net/
|
||||
# $() are not fully portable (POSIX != portable).
|
||||
# shellcheck disable=SC2006
|
||||
# Disable source following.
|
||||
# shellcheck disable=SC1090,SC1091
|
||||
|
||||
ARGV0=`basename "$0"`
|
||||
ARGV0="`basename "$0"`"
|
||||
|
||||
# load test helpers
|
||||
# Load test helpers.
|
||||
. ./shunit2_test_helpers
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# suite tests
|
||||
#
|
||||
|
||||
testStandalone()
|
||||
{
|
||||
assertTrue ${SHUNIT_TRUE}
|
||||
testStandalone() {
|
||||
assertTrue "${SHUNIT_TRUE}"
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# main
|
||||
#
|
||||
|
||||
main()
|
||||
{
|
||||
main() {
|
||||
${TH_SHUNIT} "${ARGV0}"
|
||||
}
|
||||
|
||||
# are we running as a standalone?
|
||||
# Are we running as a standalone?
|
||||
if [ "${ARGV0}" = 'shunit2_test_standalone.sh' ]; then
|
||||
if [ $# -gt 0 ]; then main "$@"; else main; fi
|
||||
fi
|
@@ -1,104 +1,112 @@
|
||||
# $Id$
|
||||
# vim:et:ft=sh:sts=2:sw=2
|
||||
#
|
||||
# shUnit2 unit test common functions
|
||||
#
|
||||
# Copyright 2008 Kate Ward. All Rights Reserved.
|
||||
# Released under the LGPL (GNU Lesser General Public License)
|
||||
# Released under the Apache 2.0 license.
|
||||
#
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
# https://github.com/kward/shunit2
|
||||
#
|
||||
# shUnit2 unit test common functions
|
||||
### ShellCheck (http://www.shellcheck.net/)
|
||||
# Commands are purposely escaped so they can be mocked outside shUnit2.
|
||||
# shellcheck disable=SC1001,SC1012
|
||||
# expr may be antiquated, but it is the only solution in some cases.
|
||||
# shellcheck disable=SC2003
|
||||
# $() are not fully portable (POSIX != portable).
|
||||
# shellcheck disable=SC2006
|
||||
|
||||
# treat unset variables as an error when performing parameter expansion
|
||||
# Treat unset variables as an error when performing parameter expansion.
|
||||
set -u
|
||||
|
||||
# set shwordsplit for zsh
|
||||
[ -n "${ZSH_VERSION:-}" ] && setopt shwordsplit
|
||||
# Set shwordsplit for zsh.
|
||||
\[ -n "${ZSH_VERSION:-}" ] && setopt shwordsplit
|
||||
|
||||
#
|
||||
# constants
|
||||
# Constants.
|
||||
#
|
||||
|
||||
# path to shUnit2 library. can be overridden by setting SHUNIT_INC
|
||||
TH_SHUNIT=${SHUNIT_INC:-./shunit2}
|
||||
# Path to shUnit2 library. Can be overridden by setting SHUNIT_INC.
|
||||
TH_SHUNIT=${SHUNIT_INC:-./shunit2}; export TH_SHUNIT
|
||||
|
||||
# configure debugging. set the DEBUG environment variable to any
|
||||
# Configure debugging. Set the DEBUG environment variable to any
|
||||
# non-empty value to enable debug output, or TRACE to enable trace
|
||||
# output.
|
||||
TRACE=${TRACE:+'th_trace '}
|
||||
[ -n "${TRACE}" ] && DEBUG=1
|
||||
[ -z "${TRACE}" ] && TRACE=':'
|
||||
\[ -n "${TRACE}" ] && DEBUG=1
|
||||
\[ -z "${TRACE}" ] && TRACE=':'
|
||||
|
||||
DEBUG=${DEBUG:+'th_debug '}
|
||||
[ -z "${DEBUG}" ] && DEBUG=':'
|
||||
\[ -z "${DEBUG}" ] && DEBUG=':'
|
||||
|
||||
#
|
||||
# variables
|
||||
# Variables.
|
||||
#
|
||||
|
||||
th_RANDOM=0
|
||||
|
||||
#
|
||||
# functions
|
||||
# Functions.
|
||||
#
|
||||
|
||||
# message functions
|
||||
th_trace() { echo "${MY_NAME}:TRACE $@" >&2; }
|
||||
th_debug() { echo "${MY_NAME}:DEBUG $@" >&2; }
|
||||
th_info() { echo "${MY_NAME}:INFO $@" >&2; }
|
||||
th_warn() { echo "${MY_NAME}:WARN $@" >&2; }
|
||||
th_error() { echo "${MY_NAME}:ERROR $@" >&2; }
|
||||
th_fatal() { echo "${MY_NAME}:FATAL $@" >&2; }
|
||||
# Logging functions.
|
||||
th_trace() { echo "${MY_NAME}:TRACE $*" >&2; }
|
||||
th_debug() { echo "${MY_NAME}:DEBUG $*" >&2; }
|
||||
th_info() { echo "${MY_NAME}:INFO $*" >&2; }
|
||||
th_warn() { echo "${MY_NAME}:WARN $*" >&2; }
|
||||
th_error() { echo "${MY_NAME}:ERROR $*" >&2; }
|
||||
th_fatal() { echo "${MY_NAME}:FATAL $*" >&2; }
|
||||
|
||||
# output subtest name
|
||||
th_subtest() { echo " $@" >&2; }
|
||||
# Output subtest name.
|
||||
th_subtest() { echo " $*" >&2; }
|
||||
|
||||
th_oneTimeSetUp()
|
||||
{
|
||||
# these files will be cleaned up automatically by shUnit2
|
||||
th_oneTimeSetUp() {
|
||||
# These files will be cleaned up automatically by shUnit2.
|
||||
stdoutF="${SHUNIT_TMPDIR}/stdout"
|
||||
stderrF="${SHUNIT_TMPDIR}/stderr"
|
||||
returnF="${SHUNIT_TMPDIR}/return"
|
||||
expectedF="${SHUNIT_TMPDIR}/expected"
|
||||
export stdoutF stderrF returnF expectedF
|
||||
}
|
||||
|
||||
# generate a random number
|
||||
th_generateRandom()
|
||||
{
|
||||
# Generate a random number.
|
||||
th_generateRandom() {
|
||||
tfgr_random=${th_RANDOM}
|
||||
|
||||
while [ "${tfgr_random}" = "${th_RANDOM}" ]; do
|
||||
if [ -n "${RANDOM:-}" ]; then
|
||||
while \[ "${tfgr_random}" = "${th_RANDOM}" ]; do
|
||||
# shellcheck disable=SC2039
|
||||
if \[ -n "${RANDOM:-}" ]; then
|
||||
# $RANDOM works
|
||||
# shellcheck disable=SC2039
|
||||
tfgr_random=${RANDOM}${RANDOM}${RANDOM}$$
|
||||
elif [ -r '/dev/urandom' ]; then
|
||||
elif \[ -r '/dev/urandom' ]; then
|
||||
tfgr_random=`od -vAn -N4 -tu4 </dev/urandom |sed 's/^[^0-9]*//'`
|
||||
else
|
||||
tfgr_date=`date '+%H%M%S'`
|
||||
tfgr_random=`expr ${tfgr_date} \* $$`
|
||||
tfgr_random=`expr "${tfgr_date}" \* $$`
|
||||
unset tfgr_date
|
||||
fi
|
||||
[ "${tfgr_random}" = "${th_RANDOM}" ] && sleep 1
|
||||
\[ "${tfgr_random}" = "${th_RANDOM}" ] && sleep 1
|
||||
done
|
||||
|
||||
th_RANDOM=${tfgr_random}
|
||||
unset tfgr_random
|
||||
}
|
||||
|
||||
# this section returns the data section from the specified section of a file. a
|
||||
# datasection is defined by a [header], one or more lines of data, and then a
|
||||
# This section returns the data section from the specified section of a file. A
|
||||
# data section is defined by a [header], one or more lines of data, and then a
|
||||
# blank line.
|
||||
th_getDataSect()
|
||||
{
|
||||
th_getDataSect() {
|
||||
th_sgrep "\\[$1\\]" "$2" |sed '1d'
|
||||
}
|
||||
|
||||
# this function greps a section from a file. a section is defined as a group of
|
||||
# lines preceeded and followed by blank lines.
|
||||
th_sgrep()
|
||||
{
|
||||
# This function greps a section from a file. a section is defined as a group of
|
||||
# lines preceded and followed by blank lines..
|
||||
th_sgrep() {
|
||||
th_pattern_=$1
|
||||
shift
|
||||
|
||||
# shellcheck disable=SC2068
|
||||
sed -e '/./{H;$!d;}' -e "x;/${th_pattern_}/"'!d;' $@ |sed '1d'
|
||||
|
||||
unset th_pattern_
|
||||
@@ -113,15 +121,14 @@ th_sgrep()
|
||||
# th_rtrn_: integer: the return value of the subtest performed
|
||||
# th_stdout_: string: filename where stdout was redirected to
|
||||
# th_stderr_: string: filename where stderr was redirected to
|
||||
th_assertTrueWithNoOutput()
|
||||
{
|
||||
th_assertTrueWithNoOutput() {
|
||||
th_test_=$1
|
||||
th_rtrn_=$2
|
||||
th_stdout_=$3
|
||||
th_stderr_=$4
|
||||
|
||||
assertTrue "${th_test_}; expected return value of zero" ${th_rtrn_}
|
||||
[ ${th_rtrn_} -ne ${SHUNIT_TRUE} ] && cat "${th_stderr_}"
|
||||
assertTrue "${th_test_}; expected return value of zero" "${th_rtrn_}"
|
||||
\[ "${th_rtrn_}" -ne "${SHUNIT_TRUE}" ] && \cat "${th_stderr_}"
|
||||
assertFalse "${th_test_}; expected no output to STDOUT" \
|
||||
"[ -s '${th_stdout_}' ]"
|
||||
assertFalse "${th_test_}; expected no output to STDERR" \
|
||||
@@ -145,13 +152,13 @@ th_assertFalseWithOutput()
|
||||
th_stdout_=$3
|
||||
th_stderr_=$4
|
||||
|
||||
assertFalse "${th_test_}; expected non-zero return value" ${th_rtrn_}
|
||||
assertFalse "${th_test_}; expected non-zero return value" "${th_rtrn_}"
|
||||
assertTrue "${th_test_}; expected output to STDOUT" \
|
||||
"[ -s '${th_stdout_}' ]"
|
||||
assertFalse "${th_test_}; expected no output to STDERR" \
|
||||
"[ -s '${th_stderr_}' ]"
|
||||
[ -s "${th_stdout_}" -a ! -s "${th_stderr_}" ] || \
|
||||
_th_showOutput ${SHUNIT_FALSE} "${th_stdout_}" "${th_stderr_}"
|
||||
\[ -s "${th_stdout_}" -a ! -s "${th_stderr_}" ] || \
|
||||
_th_showOutput "${SHUNIT_FALSE}" "${th_stdout_}" "${th_stderr_}"
|
||||
|
||||
unset th_test_ th_rtrn_ th_stdout_ th_stderr_
|
||||
}
|
||||
@@ -164,20 +171,19 @@ th_assertFalseWithOutput()
|
||||
# th_rtrn_: integer: the return value of the subtest performed
|
||||
# th_stdout_: string: filename where stdout was redirected to
|
||||
# th_stderr_: string: filename where stderr was redirected to
|
||||
th_assertFalseWithError()
|
||||
{
|
||||
th_assertFalseWithError() {
|
||||
th_test_=$1
|
||||
th_rtrn_=$2
|
||||
th_stdout_=$3
|
||||
th_stderr_=$4
|
||||
|
||||
assertFalse "${th_test_}; expected non-zero return value" ${th_rtrn_}
|
||||
assertFalse "${th_test_}; expected non-zero return value" "${th_rtrn_}"
|
||||
assertFalse "${th_test_}; expected no output to STDOUT" \
|
||||
"[ -s '${th_stdout_}' ]"
|
||||
assertTrue "${th_test_}; expected output to STDERR" \
|
||||
"[ -s '${th_stderr_}' ]"
|
||||
[ ! -s "${th_stdout_}" -a -s "${th_stderr_}" ] || \
|
||||
_th_showOutput ${SHUNIT_FALSE} "${th_stdout_}" "${th_stderr_}"
|
||||
\[ ! -s "${th_stdout_}" -a -s "${th_stderr_}" ] || \
|
||||
_th_showOutput "${SHUNIT_FALSE}" "${th_stdout_}" "${th_stderr_}"
|
||||
|
||||
unset th_test_ th_rtrn_ th_stdout_ th_stderr_
|
||||
}
|
||||
@@ -186,34 +192,33 @@ th_assertFalseWithError()
|
||||
# when a non-zero return value is encountered. To properly catch these values,
|
||||
# they are either written to disk, or recognized as an error the file is empty.
|
||||
th_clearReturn() { cp /dev/null "${returnF}"; }
|
||||
th_queryReturn()
|
||||
{
|
||||
if [ -s "${returnF}" ]; then
|
||||
th_return=`cat "${returnF}"`
|
||||
th_queryReturn() {
|
||||
if \[ -s "${returnF}" ]; then
|
||||
th_return=`\cat "${returnF}"`
|
||||
else
|
||||
th_return=${SHUNIT_ERROR}
|
||||
fi
|
||||
export th_return
|
||||
}
|
||||
|
||||
# Providing external and internal calls to the showOutput helper function.
|
||||
th_showOutput() { _th_showOutput $@; }
|
||||
_th_showOutput()
|
||||
{
|
||||
th_showOutput() { _th_showOutput "$@"; }
|
||||
_th_showOutput() {
|
||||
_th_return_=$1
|
||||
_th_stdout_=$2
|
||||
_th_stderr_=$3
|
||||
|
||||
isSkipping
|
||||
if [ $? -eq ${SHUNIT_FALSE} -a ${_th_return_} != ${SHUNIT_TRUE} ]; then
|
||||
if [ -n "${_th_stdout_}" -a -s "${_th_stdout_}" ]; then
|
||||
if \[ $? -eq "${SHUNIT_FALSE}" -a "${_th_return_}" != "${SHUNIT_TRUE}" ]; then
|
||||
if \[ -n "${_th_stdout_}" -a -s "${_th_stdout_}" ]; then
|
||||
echo '>>> STDOUT' >&2
|
||||
cat "${_th_stdout_}" >&2
|
||||
\cat "${_th_stdout_}" >&2
|
||||
fi
|
||||
if [ -n "${_th_stderr_}" -a -s "${_th_stderr_}" ]; then
|
||||
if \[ -n "${_th_stderr_}" -a -s "${_th_stderr_}" ]; then
|
||||
echo '>>> STDERR' >&2
|
||||
cat "${_th_stderr_}" >&2
|
||||
\cat "${_th_stderr_}" >&2
|
||||
fi
|
||||
if [ -n "${_th_stdout_}" -o -n "${_th_stderr_}" ]; then
|
||||
if \[ -n "${_th_stdout_}" -o -n "${_th_stderr_}" ]; then
|
||||
echo '<<< end output' >&2
|
||||
fi
|
||||
fi
|
||||
@@ -222,7 +227,7 @@ _th_showOutput()
|
||||
}
|
||||
|
||||
#
|
||||
# main
|
||||
# Main.
|
||||
#
|
||||
|
||||
${TRACE} 'trace output enabled'
|
@@ -1,89 +0,0 @@
|
||||
# $Id$
|
||||
|
||||
PROG=shunit2
|
||||
|
||||
BIN_DIR=$(PWD)/bin
|
||||
BUILD_DIR=$(PWD)/build
|
||||
DIST_DIR=$(PWD)/dist
|
||||
LIB_DIR=$(PWD)/lib
|
||||
SHARE_DIR=$(PWD)/share
|
||||
SRC_DIR=$(PWD)/src
|
||||
TEST_DIR=$(PWD)/test
|
||||
TMP_DIR=$(PWD)/tmp
|
||||
|
||||
DOCBOOK_BUILD_DIR=$(BUILD_DIR)/docbook
|
||||
DOCBOOK_SHARE_DIR=$(SHARE_DIR)/docbook
|
||||
|
||||
DOCBOOK_SRC_DIR=$(SRC_DIR)/docbook
|
||||
EXAMPLES_SRC_DIR=$(SRC_DIR)/examples
|
||||
SHELL_SRC_DIR=$(SRC_DIR)/shell
|
||||
TEST_SRC_DIR=$(SRC_DIR)/test
|
||||
|
||||
HTML_XSL=$(SHARE_DIR)/docbook/tldp-xsl/21MAR2004/html/tldp-one-page.xsl
|
||||
|
||||
all: build docs
|
||||
|
||||
build: build-prep
|
||||
cp -p $(SHELL_SRC_DIR)/$(PROG) $(BUILD_DIR)
|
||||
|
||||
build-clean:
|
||||
rm -fr $(BUILD_DIR)
|
||||
|
||||
build-prep:
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
|
||||
docs: docs-transform-shelldoc docs-transform-docbook
|
||||
|
||||
docs-prep:
|
||||
@mkdir -p $(DOCBOOK_BUILD_DIR)
|
||||
@echo "Preparing documentation for parsing"
|
||||
@isoDate=`date "+%Y-%m-%d"`; \
|
||||
find $(DOCBOOK_SRC_DIR) -name "*.xml" |\
|
||||
while read f; do \
|
||||
bn=`basename $$f`; \
|
||||
sed -e "s/@@ISO_DATE@@/$$isoDate/g" $$f >$(DOCBOOK_BUILD_DIR)/$$bn; \
|
||||
done
|
||||
|
||||
docs-extract-shelldoc: docs-prep
|
||||
@echo "Extracting the ShellDoc"
|
||||
@$(BIN_DIR)/extractDocs.pl $(SHELL_SRC_DIR)/$(PROG) >$(BUILD_DIR)/$(PROG)_shelldoc.xml
|
||||
|
||||
docs-transform-shelldoc: docs-prep docs-extract-shelldoc
|
||||
@echo "Parsing the extracted ShellDoc"
|
||||
@xsltproc $(SHARE_DIR)/resources/shelldoc.xslt $(BUILD_DIR)/$(PROG)_shelldoc.xml >$(DOCBOOK_BUILD_DIR)/functions.xml
|
||||
|
||||
docs-transform-docbook: docs-docbook-prep docs-prep
|
||||
@echo "Parsing the documentation with DocBook"
|
||||
@xsltproc $(HTML_XSL) $(DOCBOOK_BUILD_DIR)/$(PROG).xml >$(BUILD_DIR)/$(PROG).html
|
||||
|
||||
docs-docbook-prep:
|
||||
@if [ ! -d "$(DOCBOOK_SHARE_DIR)/docbook-xml" \
|
||||
-o ! -d "$(DOCBOOK_SHARE_DIR)/docbook-xsl" ]; \
|
||||
then \
|
||||
echo "Preparing DocBook structure"; \
|
||||
$(BIN_DIR)/docbookPrep.sh "$(DOCBOOK_SHARE_DIR)"; \
|
||||
fi
|
||||
|
||||
test: test-prep
|
||||
@echo "executing $(PROG) unit tests"
|
||||
( cd $(TEST_DIR); $(TEST_SRC_DIR)/run-test-suite )
|
||||
|
||||
test-clean:
|
||||
rm -fr $(TEST_DIR)
|
||||
|
||||
test-prep: build test-clean
|
||||
@mkdir -p $(TEST_DIR)
|
||||
cp -p $(TEST_SRC_DIR)/test* $(TEST_DIR)
|
||||
cp -p $(TEST_SRC_DIR)/run-test-suite $(TEST_DIR)
|
||||
cp -p $(BUILD_DIR)/$(PROG) $(TEST_DIR)
|
||||
|
||||
dist: dist-clean build docs
|
||||
@mkdir $(DIST_DIR)
|
||||
cp -p $(BUILD_DIR)/$(PROG) $(DIST_DIR)
|
||||
cp -p $(BUILD_DIR)/$(PROG).html $(DIST_DIR)
|
||||
|
||||
clean: build-clean test-clean
|
||||
rm -fr $(TMP_DIR)
|
||||
|
||||
dist-clean: clean
|
||||
rm -fr $(DIST_DIR)
|
@@ -1,97 +0,0 @@
|
||||
#! /bin/sh
|
||||
# $Id$
|
||||
|
||||
XML_VERSION='4.4'
|
||||
XML_FILE="docbook-xml-${XML_VERSION}"
|
||||
XML_URL="http://www.docbook.org/xml/${XML_VERSION}/${XML_FILE}.zip"
|
||||
|
||||
XSL_VERSION='1.72.0'
|
||||
XSL_FILE="docbook-xsl-${XSL_VERSION}"
|
||||
XSL_URL="http://downloads.sourceforge.net/docbook/${XSL_FILE}.tar.bz2"
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# do no edit below here
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
PATH="${PATH}:${MY_DIR}"
|
||||
PWD=${PWD:-`pwd`}
|
||||
|
||||
MY_BASE=`basename "$0"`
|
||||
MY_DIR=`dirname "$0"`
|
||||
|
||||
# load shlib
|
||||
. "${MY_DIR}/../lib/sh/shlib"
|
||||
|
||||
BASE_DIR=`shlib_relToAbsPath "${MY_DIR}/.."`
|
||||
DL_DIR="${BASE_DIR}/tmp"
|
||||
DOCBOOK_DIR="${BASE_DIR}/share/docbook"
|
||||
|
||||
CURL_OPTS='-C - -Os'
|
||||
WGET_OPTS='-cq'
|
||||
|
||||
METHOD_NONE=0
|
||||
METHOD_WGET=1
|
||||
METHOD_CURL=2
|
||||
|
||||
get_url()
|
||||
{
|
||||
url=$1
|
||||
case ${method} in
|
||||
${METHOD_CURL}) ${curl} ${CURL_OPTS} "${url}" ;;
|
||||
${METHOD_WGET}) ${wget} ${WGET_OPTS} "${url}" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# determine method
|
||||
method=${METHOD_NONE}
|
||||
wget=`which wget`
|
||||
[ $? -eq 0 ] && method=${METHOD_WGET}
|
||||
curl=`which curl`
|
||||
[ $? -eq 0 -a ${method} -eq ${METHOD_NONE} ] && method=${METHOD_CURL}
|
||||
if [ ${method} -eq ${METHOD_NONE} ]; then
|
||||
echo "unable to locate wget or curl. cannot continue"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# create download dir
|
||||
mkdir -p "${DL_DIR}"
|
||||
|
||||
# get the docbook xml files
|
||||
echo 'Docbook XML'
|
||||
echo ' downloading'
|
||||
cd ${DL_DIR}
|
||||
get_url "${XML_URL}"
|
||||
if [ -f "${DL_DIR}/${XML_FILE}.zip" ]; then
|
||||
echo ' extracting'
|
||||
xml_dir="${DOCBOOK_DIR}/docbook-xml/${XML_VERSION}"
|
||||
rm -fr "${xml_dir}"
|
||||
mkdir -p "${xml_dir}"
|
||||
cd "${xml_dir}"
|
||||
unzip -oq "${DL_DIR}/${XML_FILE}.zip"
|
||||
cd ..
|
||||
rm -f current
|
||||
ln -s "${XML_VERSION}" current
|
||||
else
|
||||
echo "error: unable to extract (${XML_FILE}.zip)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# get the docbook xslt files
|
||||
echo 'Docbook XSLT'
|
||||
echo ' downloading'
|
||||
cd ${DL_DIR}
|
||||
get_url "${XSL_URL}"
|
||||
if [ -f "${DL_DIR}/${XSL_FILE}.tar.bz2" ]; then
|
||||
echo ' extracting'
|
||||
xsl_dir="${DOCBOOK_DIR}/docbook-xsl"
|
||||
mkdir -p "${xsl_dir}"
|
||||
cd "${xsl_dir}"
|
||||
rm -fr ${XSL_VERSION}
|
||||
bzip2 -dc "${DL_DIR}/${XSL_FILE}.tar.bz2" |tar xf -
|
||||
mv ${XSL_FILE} ${XSL_VERSION}
|
||||
rm -f current
|
||||
ln -s "${XSL_VERSION}" current
|
||||
else
|
||||
echo "error: unable to extract (${XSL_FILE}.tar.bz2)" >&2
|
||||
exit 1
|
||||
fi
|
@@ -1,40 +0,0 @@
|
||||
#! /usr/bin/perl
|
||||
# $Id$
|
||||
|
||||
if(@ARGV != 1) {
|
||||
print "usage: $0 sourceFile\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$sourceFile = $ARGV[0];
|
||||
|
||||
#
|
||||
# read in the source file
|
||||
#
|
||||
$rslt = open(FILE, $sourceFile)
|
||||
|| die "could not open file ($sourceFile)";
|
||||
|
||||
$inComment = 0;
|
||||
while(<FILE>) {
|
||||
next if /^[^#]/;
|
||||
s/^# //;
|
||||
s/^#//;
|
||||
|
||||
if(/^\/\*\*/) {
|
||||
$inComment = 1;
|
||||
next;
|
||||
}
|
||||
if(/\*\/$/) {
|
||||
$inComment = 0;
|
||||
next;
|
||||
}
|
||||
|
||||
if ($inComment == 1) { print $_ };
|
||||
if ($inComment == 0 && /\/\/\*/) {
|
||||
@line = split /\/\/\*/, $_, 2;
|
||||
$line[1] =~ s/^ //;
|
||||
print $line[1];
|
||||
}
|
||||
}
|
||||
|
||||
close(FILE);
|
@@ -1,36 +0,0 @@
|
||||
#! /bin/sh
|
||||
# $Id$
|
||||
#
|
||||
# This is a simple implementation of the 'which' command for those OSes that
|
||||
# don't have one.
|
||||
#
|
||||
|
||||
true; TRUE=$?
|
||||
false; FALSE=$?
|
||||
|
||||
showAll=${FALSE}
|
||||
|
||||
# process command line flags
|
||||
while getopts 'a' opt; do
|
||||
case ${opt} in
|
||||
a) showAll=${TRUE}
|
||||
esac
|
||||
done
|
||||
shift `expr ${OPTIND} - 1`
|
||||
|
||||
# exit if no arguments were given
|
||||
[ $# -eq 0 ] && exit 1
|
||||
|
||||
command=$1
|
||||
|
||||
# search for command
|
||||
out=`echo "${PATH}" |sed "s/:/\n/g" |\
|
||||
while read path; do
|
||||
fullPath="${path}/${command}"
|
||||
if [ -x "${fullPath}" ]; then
|
||||
echo "${fullPath}"
|
||||
[ ${showAll} -eq ${FALSE} ] && break
|
||||
fi
|
||||
done`
|
||||
[ -z "${out}" ] && exit 1
|
||||
echo "${out}"
|
@@ -1,68 +0,0 @@
|
||||
CHANGES WITH 2.0.4
|
||||
|
||||
Unset additional variables that were missed.
|
||||
|
||||
Fixed off-by-one in exit value for scripts caught by the trap handler.
|
||||
|
||||
The library did not fail gracefully when the 'od' command was not installed.
|
||||
|
||||
|
||||
CHANGES WITH 2.0.3
|
||||
|
||||
Back ported the Makefile from 2.1.1pre that included changes to the
|
||||
docs-docbook-prep target.
|
||||
|
||||
Changed the test in assertFalse() so that any non-zero value registers as
|
||||
false. (Credits to Bryan Larsen)
|
||||
|
||||
Updated the testPartyLikeItIs1999() function in the Quick Start documentation.
|
||||
The 'expected' and 'actual' values were swapped. (Credits to Richard Jensen)
|
||||
|
||||
It was pointed out that the simple 'failed' message for a failed assert was not
|
||||
only insufficient, it was nonstandard (when compared to JUnit) and didn't
|
||||
provide the user with an expected vs actual result. The code was revised
|
||||
somewhat to bring closer into alignment with JUnit (v4.3.1 specifically) so
|
||||
that it feels more "normal". (Credits to Richard Jensen)
|
||||
|
||||
As part of the JUnit realignment, it was noticed that fail*() functions in
|
||||
JUnit don't actually do any comparisons themselves. They only generate a
|
||||
failure message. Updated the code to match.
|
||||
|
||||
Added self-testing unit tests. Kinda horkey, but they did find bugs during the
|
||||
JUnit realignment.
|
||||
|
||||
Fixed the code for returning from asserts as the return was being called before
|
||||
the unsetting of variables occurred. (Credits to Mathias Goldau)
|
||||
|
||||
The assert(True|False)() functions now accept an integer value for a
|
||||
conditional test. A value of '0' is considered 'true', while any non-zero value
|
||||
is considered 'false'.
|
||||
|
||||
All public functions now fill use default values to work properly with the '-x'
|
||||
shell debugging flag.
|
||||
|
||||
Fixed the method of percent calculation for the report to get achieve better
|
||||
accuracy.
|
||||
|
||||
|
||||
CHANGES WITH 2.0.2
|
||||
|
||||
Fixed problem with fail(). The failure message was not properly printed.
|
||||
|
||||
Reworked the Makefile so that the DocBook XML and XSLT files are properly
|
||||
downloaded before parsing can continue.
|
||||
|
||||
|
||||
CHANGES WITH 2.0.1
|
||||
|
||||
Fixed some really stupid mistakes with the fail* functions. They were doing the
|
||||
exact opposite of what they were supposed to be doing.
|
||||
|
||||
|
||||
CHANGES WITH 2.0.0
|
||||
|
||||
Made the first stand-alone release!
|
||||
|
||||
|
||||
$Revision$
|
||||
vim:spell
|
@@ -1,504 +0,0 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
@@ -1,153 +0,0 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# SourceForge
|
||||
#
|
||||
|
||||
This project is stored on SourceForge as http://sf.net/projects/shunit2. The
|
||||
source code can be accessed using the following information.
|
||||
|
||||
* Subversion
|
||||
$ svn co https://shunit2.svn.sourceforge.net/svnroot/shunit2/trunk/source shunit2
|
||||
|
||||
Subversion may also be browsed via a web browser at
|
||||
http://svn.sourceforge.net/shunit2
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Making a release
|
||||
#
|
||||
|
||||
For these steps, it is assumed we are working with release 2.0.0.
|
||||
|
||||
Steps:
|
||||
* write release notes
|
||||
* update version
|
||||
* finish changelog
|
||||
* check all the code in
|
||||
* tag the release
|
||||
* export the release
|
||||
* create tarball
|
||||
* md5sum the tarball and sign with gpg
|
||||
* update website
|
||||
* post to SourceForge and Freshmeat
|
||||
|
||||
WRITE RELEASE NOTES
|
||||
|
||||
This should be pretty self explainatory. Use one of the release notes from a
|
||||
previous release as an example.
|
||||
|
||||
To get the versions of the various shells, do the following:
|
||||
Cygwin
|
||||
bash: $ bash --version
|
||||
ksh: actually pdksh
|
||||
pdksh: look in the downloaded Cygwin directory
|
||||
Linux
|
||||
bash: $ bash --version
|
||||
dash: look at installed version
|
||||
ksh: $ ksh --version
|
||||
pdksh: $ strings /bin/pdksh |grep 'PD KSH'
|
||||
zsh: $ zsh --version
|
||||
Solaris 10
|
||||
sh: not possible
|
||||
bash: $ bash --version
|
||||
ksh: $ strings /usr/bin/ksh |grep 'Version'
|
||||
|
||||
UPDATE VERSION
|
||||
|
||||
Edit the shunit2 source code, and change the version number in the comment, as
|
||||
well as in the __SHUNIT_VERSION variable. Next, edit the
|
||||
src/docbook/shunit2.xml file, edit the version in the <title> element, and make
|
||||
sure there is a revision section for this release.
|
||||
|
||||
FINISH DOCUMENTATION
|
||||
|
||||
Make sure that any remaning changes get put into the CHANGES-X.X.txt file.
|
||||
|
||||
Finish writing the RELEASE_NOTES-X.X.X.txt. Once it is finished, run it through
|
||||
the 'fmt' command to make it pretty.
|
||||
|
||||
$ fmt -w 80 RELEASE_NOTES-2.0.0.txt >RELEASE_NOTES-2.0.0.txt.new
|
||||
$ mv RELEASE_NOTES-2.0.0.txt.new RELEASE_NOTES-2.0.0.txt
|
||||
|
||||
We want to have an up-to-date version of the documentation in the release, so
|
||||
we'd better build it.
|
||||
|
||||
$ pwd
|
||||
.../shunit2/source/2.0
|
||||
$ make docs
|
||||
...
|
||||
$ cp -p build/shunit2.html doc
|
||||
$ svn ci -m "" doc/shunit2.html
|
||||
|
||||
CHECK IN ALL THE CODE
|
||||
|
||||
This step is pretty self-explainatory
|
||||
|
||||
TAG THE RELEASE
|
||||
|
||||
$ pwd
|
||||
.../shunit2/source
|
||||
$ ls
|
||||
2.0 2.1
|
||||
$ svn cp -m "Release 2.0.0" \
|
||||
2.0 https://shunit2.svn.sourceforge.net/svnroot/shunit2/tags/source/2.0.0
|
||||
|
||||
EXPORT THE RELEASE
|
||||
|
||||
$ pwd
|
||||
.../shunit2/builds
|
||||
$ svn export \
|
||||
https://shunit2.svn.sourceforge.net/svnroot/shunit2/tags/source/2.0.0 \
|
||||
shunit2-2.0.0
|
||||
|
||||
CREATE TARBALL
|
||||
|
||||
$ tar cfz ../releases/shunit2-2.0.0.tgz shunit2-2.0.0
|
||||
|
||||
MD5SUM THE TARBALL AND SIGN WITH GPG
|
||||
|
||||
$ cd ../releases
|
||||
$ md5sum shunit2-2.0.0.tgz >shunit2-2.0.0.tgz.md5
|
||||
$ gpg --default-key kate.ward@forestent.com --detach-sign shunit2-2.0.0.tgz
|
||||
|
||||
UPDATE WEBSITE
|
||||
|
||||
Again, pretty self-explainatory. Make sure to copy the MD5 and GPG signature
|
||||
files. Once that is done, make sure to tag the website so we can go back in
|
||||
time if needed.
|
||||
|
||||
$ pwd
|
||||
.../shunit2
|
||||
$ ls
|
||||
source website
|
||||
$ svn cp -m "Release 2.0.0" \
|
||||
website https://shunit2.svn.sourceforge.net/svnroot/shunit2/tags/website/20060916
|
||||
|
||||
Now, update the website. It too is held in Subversion, so ssh into SourceForge
|
||||
and use 'svn up' to grab the latest version.
|
||||
|
||||
POST TO SOURCEFORGE AND FRESHMEAT
|
||||
|
||||
http://sourceforge.net/projects/shunit2/
|
||||
http://freshmeat.net/
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Related documentation
|
||||
#
|
||||
|
||||
Docbook XML
|
||||
docbook-xml-4.4.zip
|
||||
http://www.docbook.org/xml/4.4/docbook-xml-4.4.zip
|
||||
http://www.oasis-open.org/docbook/xml/4.4/docbook-xml-4.4.zip
|
||||
docbook-xml-4.5.zip
|
||||
http://www.docbook.org/xml/4.5/docbook-xml-4.5.zip
|
||||
|
||||
Docbook XSL
|
||||
docbook-xsl-1.71.0.tar.bz2
|
||||
http://prdownloads.sourceforge.net/docbook/docbook-xsl-1.71.0.tar.bz2?download
|
||||
docbook-xsl-1.71.1.tar.bz2
|
||||
http://downloads.sourceforge.net/docbook/docbook-xsl-1.71.1.tar.bz2?use_mirror=puzzle
|
||||
|
||||
JUnit
|
||||
http://www.junit.org
|
||||
|
||||
|
||||
$Revision$
|
@@ -1,71 +0,0 @@
|
||||
RELEASE NOTES FOR 2.0.0
|
||||
|
||||
This is the initial release of shunit2. It was originally included in log4sh
|
||||
1.3.5 [http://log4sh.sourceforge.net/] as a unit testing framework for that
|
||||
product. It has since grown table enough to warrant being released into the
|
||||
wild on its own.
|
||||
|
||||
|
||||
TESTED PLATFORMS
|
||||
|
||||
This list of platforms comes from the latest version of log4sh as shunit2 is
|
||||
used in the testing of log4sh on each of these platforms.
|
||||
|
||||
Cygwin
|
||||
+ bash 3.2.9(10)
|
||||
+ pdksh 5.2.14
|
||||
|
||||
Linux
|
||||
+ bash 3.1.17(1)
|
||||
+ dash 0.5.3
|
||||
+ ksh 1993-12-28
|
||||
+ pdksh 5.2.14
|
||||
+ zsh 4.3.2 (does not work)
|
||||
|
||||
Mac OS X 1.4.8 (Darwin 8.8)
|
||||
+ bash 2.05b.0(1)
|
||||
+ ksh 1993-12-28
|
||||
|
||||
Solaris 8 U3 (x86)
|
||||
+ /bin/sh
|
||||
+ bash 2.03.0(1)
|
||||
+ ksh M-11/16/88i
|
||||
|
||||
Solaris 10 U2 (sparc)
|
||||
+ /bin/sh
|
||||
+ bash 3.00.16(1)
|
||||
+ ksh M-11/16/88i
|
||||
|
||||
Solaris 10 U2 (x86)
|
||||
+ /bin/sh
|
||||
+ bash 3.00.16(1)
|
||||
+ ksh M-11/16/88i
|
||||
|
||||
|
||||
NEW FEATURES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
CHANGES AND ENHANCEMENTS
|
||||
|
||||
None.
|
||||
|
||||
|
||||
BUG FIXES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
DEPRECATED FEATURES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
KNOWN BUGS AND ISSUES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
$Revision$
|
||||
vim:spell
|
@@ -1,73 +0,0 @@
|
||||
RELEASE NOTES FOR 2.0.1
|
||||
|
||||
This release is mostly a brown-bag release. Not so nice for the second release
|
||||
ever of the product, but that's what I get for trying to get something out
|
||||
there that I hadn't fully looked through one last time.
|
||||
|
||||
|
||||
TESTED PLATFORMS
|
||||
|
||||
This list of platforms comes from the latest version of log4sh as shunit2 is
|
||||
used in the testing of log4sh on each of these platforms.
|
||||
|
||||
Cygwin
|
||||
+ bash 3.2.9(10)
|
||||
+ pdksh 5.2.14
|
||||
|
||||
Linux
|
||||
+ bash 3.1.17(1)
|
||||
+ dash 0.5.3
|
||||
+ ksh 1993-12-28
|
||||
+ pdksh 5.2.14
|
||||
+ zsh 4.3.2 (does not work)
|
||||
|
||||
Mac OS X 1.4.8 (Darwin 8.8)
|
||||
+ bash 2.05b.0(1)
|
||||
+ ksh 1993-12-28
|
||||
|
||||
Solaris 8 U3 (x86)
|
||||
+ /bin/sh
|
||||
+ bash 2.03.0(1)
|
||||
+ ksh M-11/16/88i
|
||||
|
||||
Solaris 10 U2 (sparc)
|
||||
+ /bin/sh
|
||||
+ bash 3.00.16(1)
|
||||
+ ksh M-11/16/88i
|
||||
|
||||
Solaris 10 U2 (x86)
|
||||
+ /bin/sh
|
||||
+ bash 3.00.16(1)
|
||||
+ ksh M-11/16/88i
|
||||
|
||||
|
||||
NEW FEATURES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
CHANGES AND ENHANCEMENTS
|
||||
|
||||
The documentation regarding the assertTrue() and assertFalse() functions was
|
||||
updated to reflect their proper usage. They are shell test condition evaluators
|
||||
(e.g. "[1 -eq 2]") rather than simple 0/1 comparators.
|
||||
|
||||
|
||||
BUG FIXES
|
||||
|
||||
The fail*() functions were doing the exact opposite of what they were supposed
|
||||
to be doing. They have been fixed.
|
||||
|
||||
|
||||
DEPRECATED FEATURES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
KNOWN BUGS AND ISSUES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
$Revision$
|
||||
vim:spell
|
@@ -1,71 +0,0 @@
|
||||
RELEASE NOTES FOR 2.0.2
|
||||
|
||||
This is solely a bug-fix release.
|
||||
|
||||
|
||||
TESTED PLATFORMS
|
||||
|
||||
This list of platforms comes from the latest version of log4sh as shUnit2 is
|
||||
used in the testing of log4sh on each of these platforms.
|
||||
|
||||
Cygwin
|
||||
+ bash 3.2.9(10)
|
||||
+ pdksh 5.2.14
|
||||
|
||||
Linux
|
||||
+ bash 3.1.17(1)
|
||||
+ dash 0.5.3
|
||||
+ ksh 1993-12-28
|
||||
+ pdksh 5.2.14
|
||||
+ zsh 4.3.2 (does not work)
|
||||
|
||||
Mac OS X 1.4.8 (Darwin 8.8)
|
||||
+ bash 2.05b.0(1)
|
||||
+ ksh 1993-12-28
|
||||
|
||||
Solaris 8 U3 (x86)
|
||||
+ /bin/sh
|
||||
+ bash 2.03.0(1)
|
||||
+ ksh M-11/16/88i
|
||||
|
||||
Solaris 10 U2 (sparc)
|
||||
+ /bin/sh
|
||||
+ bash 3.00.16(1)
|
||||
+ ksh M-11/16/88i
|
||||
|
||||
Solaris 10 U2 (x86)
|
||||
+ /bin/sh
|
||||
+ bash 3.00.16(1)
|
||||
+ ksh M-11/16/88i
|
||||
|
||||
|
||||
NEW FEATURES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
CHANGES AND ENHANCEMENTS
|
||||
|
||||
None.
|
||||
|
||||
|
||||
BUG FIXES
|
||||
|
||||
The fail() function did not output the optional failure message.
|
||||
|
||||
Fixed the Makefile so that the DocBook XML and XSLT files would be downloaded
|
||||
before parsing can continue.
|
||||
|
||||
|
||||
DEPRECATED FEATURES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
KNOWN BUGS AND ISSUES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
$Revision$
|
||||
vim:spell
|
@@ -1,60 +0,0 @@
|
||||
RELEASE NOTES FOR 2.0.3
|
||||
|
||||
This release incorporates a realignment with the JUnit 4 code. Asserts now
|
||||
provide better failure messages, and the failure functions no longer perform
|
||||
tests.
|
||||
|
||||
See the CHANGES-2.0.txt file for a full list of changes.
|
||||
|
||||
|
||||
TESTED PLATFORMS
|
||||
|
||||
This list of platforms comes from the latest version of log4sh as shUnit2 is
|
||||
used in the testing of log4sh on each of these platforms.
|
||||
|
||||
Cygwin -- untested
|
||||
|
||||
Linux
|
||||
- bash 3.2.13(1)
|
||||
- dash 0.5.3
|
||||
- ksh 1993-12-28
|
||||
- pdksh 5.2.14
|
||||
|
||||
Mac OS X -- untested
|
||||
Solaris 8 -- untested
|
||||
Solaris 10 -- untested
|
||||
|
||||
|
||||
NEW FEATURES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
CHANGES AND ENHANCEMENTS
|
||||
|
||||
The internal test in assertFalse() was changed so that any non-zero value is
|
||||
considered false, rather than any only values equal to 1.
|
||||
|
||||
The assertTrue() and assertFalse() functions now accept an integer value for a
|
||||
conditional test. A value of '0' is considered 'true', while any non-zero value
|
||||
is considered 'false'.
|
||||
|
||||
Self-testing unit tests were added.
|
||||
|
||||
|
||||
BUG FIXES
|
||||
|
||||
All asserts now properly unset their variables.
|
||||
|
||||
|
||||
DEPRECATED FEATURES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
KNOWN BUGS AND ISSUES
|
||||
|
||||
Functions do not properly test for an invalid number of arguments.
|
||||
|
||||
|
||||
vim:spell
|
@@ -1,51 +0,0 @@
|
||||
RELEASE NOTES FOR 2.0.4
|
||||
|
||||
This is a minor bugfix release.
|
||||
|
||||
See the CHANGES-2.0.txt file for a full list of changes.
|
||||
|
||||
|
||||
TESTED PLATFORMS
|
||||
|
||||
This list of platforms comes from the latest version of log4sh as shUnit2 is
|
||||
used in the testing of log4sh on each of these platforms.
|
||||
|
||||
Cygwin -- untested
|
||||
|
||||
Linux
|
||||
- bash 3.2.13(1)
|
||||
- dash 0.5.3
|
||||
- ksh 1993-12-28
|
||||
- pdksh 5.2.14
|
||||
|
||||
Mac OS X -- untested
|
||||
Solaris 8 -- untested
|
||||
Solaris 10 -- untested
|
||||
|
||||
|
||||
NEW FEATURES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
CHANGES AND ENHANCEMENTS
|
||||
|
||||
None.
|
||||
|
||||
|
||||
BUG FIXES
|
||||
|
||||
The library no longer fails when the 'od' command is not present.
|
||||
|
||||
|
||||
DEPRECATED FEATURES
|
||||
|
||||
None.
|
||||
|
||||
|
||||
KNOWN BUGS AND ISSUES
|
||||
|
||||
Functions do not properly test for an invalid number of arguments.
|
||||
|
||||
|
||||
vim:spell
|
@@ -1,5 +0,0 @@
|
||||
Make it possible to execute a single test by passing the name of the test on
|
||||
the command line
|
||||
|
||||
|
||||
$Revision$
|
@@ -1,10 +0,0 @@
|
||||
The original author of shunit2 is Kate Ward. The following people have
|
||||
contributed in some way or another to shunit2.
|
||||
|
||||
Bryan Larsen
|
||||
Kevin Van Horn
|
||||
Mathias Goldau
|
||||
Richard Jensen
|
||||
Rob Holland
|
||||
|
||||
$Revision$
|
@@ -1,54 +0,0 @@
|
||||
Design Doc for shUnit2
|
||||
======================
|
||||
|
||||
shUnit is based upon JUnit. The initial ideas for the script came from the book
|
||||
"Pragmatic Unit Testing - In Java with JUnit" by Andrew Hunt and David Thomas.
|
||||
|
||||
The script was written to perform unit testing for log4sh. log4sh had grown
|
||||
enough that it was becoming difficult to easily test and and verify that the
|
||||
tests passed for the many different operating systems on which it was being
|
||||
used.
|
||||
|
||||
The functions in shUnit are meant to match those in JUnit as much as possible
|
||||
where shell allows. In the initial version, there will be no concept of
|
||||
exceptions (as normal POSIX shell has no concept of them) but attempts to trap
|
||||
problems will be done.
|
||||
|
||||
Programatic Standards
|
||||
---------------------
|
||||
|
||||
* SHUNIT_TRUE - public global constant
|
||||
* __SHUNIT_SHELL_FLAGS - private global constant
|
||||
* __shunit_oldShellFlags - private global variable
|
||||
|
||||
* assertEquals - public unit test function
|
||||
* shunit_publicFunc - public shUnit function; can be called from parent unit
|
||||
test script
|
||||
* _shunit_privateFunc - private shUnit function; should not be called from
|
||||
parent script. meant for internal use by shUnit
|
||||
|
||||
* _su_myVar - variable inside a public function. prefixing with '_su_' to
|
||||
reduce the chances that a variable outside of shUnit will be overridden.
|
||||
* _su__myVar - variable inside a private function. prefixing with '_su__' to
|
||||
reduce the chances that a variable in a shUnit public function, or a variable
|
||||
outside of shUnit will be overridden.
|
||||
|
||||
List of functions
|
||||
-----------------
|
||||
|
||||
assertTrue([message,] boolean)
|
||||
assertFalse([message,] boolean)
|
||||
fail([message])
|
||||
assertEquals([message,] expected, actual)
|
||||
#isEquals(expected, actual)
|
||||
#assertArrayEquals([message,] expecteds, actuals)
|
||||
#isArray(expected)
|
||||
assertNotNull([message,] object)
|
||||
assertNull([message,], object)
|
||||
assertSame([message,], expected, actual)
|
||||
assertNotSame([message,], unexpected, actual)
|
||||
failSame(message)
|
||||
failNotSame([message,] expected, actual)
|
||||
|
||||
.. $Revision$
|
||||
.. vim:syntax=rst
|
File diff suppressed because one or more lines are too long
@@ -1,33 +0,0 @@
|
||||
/* $Id$ */
|
||||
/*
|
||||
style.css
|
||||
*/
|
||||
|
||||
|
||||
body {
|
||||
|
||||
/*
|
||||
Style the HMTL <body> tag with a sans-serif font and 6% margin.
|
||||
A sans-serif font makes documents easier to read when displayed on
|
||||
a computer screen. Whitespace surrounding the document should
|
||||
make it easier to read both on screen and on printed paper. The
|
||||
value of 6% was chosen because it closely approximates a one-half
|
||||
inch margin on a US letter (8.5" by 11") paper. Since the margin
|
||||
is expressed as a percentage it should scale well in a web browser
|
||||
window.
|
||||
*/
|
||||
|
||||
font-family: sans-serif;
|
||||
margin: 6%;
|
||||
}
|
||||
|
||||
/*
|
||||
table {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
*/
|
||||
|
||||
.toc {
|
||||
background: #f0f0f0;
|
||||
padding: 5px;
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
# $Id$
|
||||
# vim:syntax=sh
|
||||
#
|
||||
# library of shell functions
|
||||
#
|
||||
|
||||
shlib_relToAbsPath()
|
||||
{
|
||||
_shlib_path=$1
|
||||
|
||||
# deal with paths that start with /
|
||||
echo "${_shlib_path}" |grep '^/' >/dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
_shlib_pwd=`pwd`
|
||||
_shlib_path="${_shlib_pwd}/${_shlib_path}"
|
||||
unset _shlib_pwd
|
||||
fi
|
||||
|
||||
# clean up the path
|
||||
echo "${_shlib_path}" |sed 's/[^/]*\/*\.\.\/*//g;s/\/\.\//\//'
|
||||
|
||||
unset _shlib_path
|
||||
}
|
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<xsl:import href="../../../docbook-xsl/current/fo/docbook.xsl"/>
|
||||
|
||||
<!-- Number all sections in the style of 'CH.S1.S2 Section Title' where
|
||||
CH is the chapter number, S1 is the section number and S2 is the
|
||||
sub-section number. The lables are not limited to any particular
|
||||
depth and can go as far as there are sections. -->
|
||||
<xsl:param name="section.autolabel" select="1"></xsl:param>
|
||||
<xsl:param name="section.label.includes.component.label" select="0"></xsl:param>
|
||||
|
||||
<!-- Turn off the default 'full justify' and go with 'left justify'
|
||||
instead. This avoids the large gaps that can sometimes appear
|
||||
between words in fully-justified documents. -->
|
||||
<xsl:param name="alignment">start</xsl:param>
|
||||
|
||||
<!-- Shade Verbatim Sections such as programlisting and screen -->
|
||||
<xsl:param name="shade.verbatim" select="1"/>
|
||||
|
||||
<!-- Create bookmarks in .PDF files -->
|
||||
<xsl:param name="fop.extensions" select="1"/>
|
||||
|
||||
</xsl:stylesheet>
|
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<!-- This file contains parameters that are applicable to all of the
|
||||
tldp-*.xsl files in the html directory. -->
|
||||
|
||||
<!-- Create a link to a CSS stylesheet named 'style.css' in all html
|
||||
output so that pages can be beautified. Browsers not supporting
|
||||
CSS should safely ignore the link. -->
|
||||
<xsl:param name="html.stylesheet.type">text/css</xsl:param>
|
||||
<xsl:param name="html.stylesheet" select="'style.css'"></xsl:param>
|
||||
|
||||
<!-- Number all sections in the style of 'CH.S1.S2 Section Title' where
|
||||
CH is the chapter number, S1 is the section number and S2 is the
|
||||
sub-section number. The lables are not limited to any particular
|
||||
depth and can go as far as there are sections. -->
|
||||
<xsl:param name="section.autolabel" select="1"></xsl:param>
|
||||
<xsl:param name="section.label.includes.component.label" select="0"></xsl:param>
|
||||
|
||||
</xsl:stylesheet>
|
@@ -1,13 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||
|
||||
<xsl:import href="../../../docbook-xsl/current/html/docbook.xsl"/>
|
||||
<xsl:import href="tldp-common.xsl"/>
|
||||
<xsl:output method="html" encoding="UTF-8" indent="no"/>
|
||||
|
||||
<!-- This set of customizations is used to generate the entire XML
|
||||
document on a single HTML page. -->
|
||||
|
||||
</xsl:stylesheet>
|
@@ -1,71 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- $Id$ -->
|
||||
<!--
|
||||
example ways to process this xslt:
|
||||
$ java -cp xalan-2.6.0.jar \
|
||||
org.apache.xalan.xslt.Process -xml -in log4sh.xml -xsl shelldoc.xslt
|
||||
|
||||
$ xsltproc shelldoc.xslt log4sh.xml |xmllint -noblanks -
|
||||
-->
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
xmlns:s="http://www.forestent.com/projects/shelldoc/xsl/2005.0">
|
||||
<xsl:output
|
||||
method="xml"
|
||||
version="1.0"
|
||||
encoding="UTF-8"
|
||||
indent="yes"/>
|
||||
<xsl:strip-space elements="*" />
|
||||
|
||||
<xsl:variable name="newline">
|
||||
<xsl:text>
|
||||
</xsl:text>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:key name="groups" match="s:function" use="@group" />
|
||||
|
||||
<xsl:template match="/">
|
||||
<chapter id="shelldoc" lang="en-US"><title>Function Reference</title>
|
||||
<xsl:for-each select="//s:function[generate-id(.)=generate-id(key('groups', @group)[1])]">
|
||||
<xsl:sort select="@group" />
|
||||
|
||||
<section>
|
||||
<xsl:attribute name="id">shelldoc-section-<xsl:value-of select="@group" /></xsl:attribute>
|
||||
<title><xsl:value-of select="@group"/></title>
|
||||
<table>
|
||||
<xsl:attribute name="id">shelldoc-function-<xsl:value-of select="@group" /></xsl:attribute>
|
||||
<title><xsl:value-of select="@group"/></title>
|
||||
<tgroup cols="2"><tbody>
|
||||
<xsl:for-each select="key('groups', @group)">
|
||||
<!--<xsl:sort select="entry/funcsynopsis/funcprototype/funcdef/function" />-->
|
||||
<xsl:choose>
|
||||
<xsl:when test="@modifier">
|
||||
<xsl:if test="@modifier != 'private'">
|
||||
<row valign="top">
|
||||
<xsl:copy-of select="entry" />
|
||||
<!--<xsl:apply-templates select="entry" />-->
|
||||
</row>
|
||||
</xsl:if>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<row valign="top">
|
||||
<xsl:copy-of select="entry" />
|
||||
<!--<xsl:apply-templates select="entry" />-->
|
||||
</row>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</tbody></tgroup>
|
||||
</table>
|
||||
</section>
|
||||
</xsl:for-each>
|
||||
</chapter>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="entry">
|
||||
<entry>
|
||||
<xsl:copy-of select="*" />
|
||||
</entry>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
$Id$
|
||||
vim:softtabstop=2 shiftwidth=2
|
||||
-->
|
||||
|
||||
<!-- =========================================================================
|
||||
Functions
|
||||
-->
|
||||
|
||||
<chapter id="functions">
|
||||
<title>Functions</title>
|
||||
<para>This XML file is a placeholder. It is meant to be overwritten with the dynamically generated XML document that is extracted from the source code.</para>
|
||||
</chapter>
|
@@ -1,50 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
$Id$
|
||||
vim:softtabstop=2 shiftwidth=2
|
||||
-->
|
||||
|
||||
<!-- =========================================================================
|
||||
Introduction
|
||||
-->
|
||||
|
||||
<chapter label="1" id="introduction">
|
||||
|
||||
<title>Introduction</title>
|
||||
<para>shUnit2 is a unit test framework for Bourne based shell scripts, and it is designed to work in a similar manner to <ulink url="http://www.junit.org/">JUnit</ulink>, <ulink url="http://pyunit.sourceforge.net/">PyUnit</ulink>, etc.</para>
|
||||
|
||||
<para>shUnit2 was originally developed to provide a consistent testing solution for <ulink url="http://log4sh.sourceforge.net/">log4sh</ulink>, a shell based logging framework similar to log4j. During the development of that product, the problem of having things work just fine under one shell (<filename>/bin/bash</filename> on Linux to be specific), and then not working under another shell (<filename>/bin/sh</filename> on Solaris), kept coming up. Although there were several simple tests ran, they were not adaquate and did not catch very many corner cases. The decision was finally made to write a proper unit test framework after after multiple brown-bag releases were made.</para>
|
||||
|
||||
<para><blockquote><title>Tested Operating Systems</title>
|
||||
<itemizedlist>
|
||||
<listitem><para><ulink url="http://www.cygwin.com/">Cygwin</ulink></para></listitem>
|
||||
<listitem><para><ulink url="http://www.freebsd.org/">FreeBSD</ulink> (user supported)</para></listitem>
|
||||
<listitem><para>Linux (<ulink url="http://www.gentoo.org/">Gentoo</ulink>, <ulink url="http://www.ubuntu.com/">Ubuntu</ulink>)</para></listitem>
|
||||
<listitem><para><ulink url="http://www.apple.com/macosx/">Mac OS X</ulink></para></listitem>
|
||||
<listitem><para><ulink url="http://www.sun.com/software/solaris/">Solaris</ulink> 8, 9, 10</para></listitem>
|
||||
</itemizedlist>
|
||||
</blockquote></para>
|
||||
|
||||
<para><blockquote><title>Tested Shells</title>
|
||||
<itemizedlist>
|
||||
<listitem><para>Bourne Shell (<command>sh</command>)</para></listitem>
|
||||
<listitem><para><ulink url="http://www.gnu.org/software/bash/">BASH</ulink> - GNU Bourne Again SHell (<command>bash</command>)</para></listitem>
|
||||
<listitem><para><ulink url="http://gondor.apana.org.au/~herbert/dash/">DASH</ulink> (<command>dash</command>)</para></listitem>
|
||||
<listitem><para><ulink url="http://www.kornshell.com/">Korn Shell</ulink> (<command>ksh</command>)</para></listitem>
|
||||
<listitem><para><ulink url="http://web.cs.mun.ca/~michael/pdksh/">pdksh</ulink> - Public Domain Korn Shell (<command>pdksh</command>)</para></listitem>
|
||||
</itemizedlist>
|
||||
</blockquote></para>
|
||||
|
||||
<para>See the appropriate Release Notes (<filename>doc/RELEASE_NOTES-X.X.X.txt</filename>) for this release for the actual versions tested.</para>
|
||||
|
||||
<!-- Give credit where credit is due...very important -->
|
||||
<section id="credits"><title>Credits / Contributors</title>
|
||||
<para>A list of contributors to shUnit2 can be found in the source archive as <filename>doc/contributors.txt</filename>. I want to personally thank all those who have contributed to make this a better tool.</para>
|
||||
</section>
|
||||
|
||||
<!-- Feedback -->
|
||||
<section id="feedback"><title>Feedback</title>
|
||||
<para>Feedback is most certainly welcome for this document. Send your additions, comments and criticisms to the following email address: <email>&myEmail;</email>.</para>
|
||||
</section>
|
||||
|
||||
</chapter>
|
@@ -1,86 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
$Id: quickstart.xml 230 2006-08-19 22:32:02Z sfsetse $
|
||||
vim:softtabstop=2 shiftwidth=2
|
||||
-->
|
||||
|
||||
<!-- =========================================================================
|
||||
Quickstart
|
||||
-->
|
||||
<chapter id="quickstart">
|
||||
<title>Quickstart</title>
|
||||
|
||||
<para>This chapter will give a very quick start to running unit tests with shUnit2. More information is located in other chapters.</para>
|
||||
|
||||
<para>Here is a quick sample script to show how easy it is to write a unit test in shell. It expects that you have a copy of &shunit2; in the same directory as the script.</para>
|
||||
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
#! /bin/sh
|
||||
|
||||
testEquality()
|
||||
{
|
||||
assertEquals 1 1
|
||||
}
|
||||
|
||||
# load shunit2
|
||||
. ./shunit2
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
<para>Running the unit test should give results similar to the following.</para>
|
||||
|
||||
<screen>
|
||||
<![CDATA[
|
||||
#
|
||||
# Performing tests
|
||||
#
|
||||
testEquality
|
||||
|
||||
#
|
||||
# Test report
|
||||
#
|
||||
tests passed: 1
|
||||
tests failed: 0
|
||||
tests total: 1
|
||||
success rate: 100%
|
||||
]]>
|
||||
</screen>
|
||||
|
||||
<para>Wohoo! You've just run your first successful unit test. So, what just happened? Quite a bit really, and it all happened simply by sourcing the &shunit2; script. The basic functionality for the script above goes like this.</para>
|
||||
|
||||
<para>When shUnit2 is sourced, it first looks to see if a <function>suite()</function> function has been declared. If it exists, it is called as it is expected to contain a list of tests to be executed. If it doesn't exist (and it doesn't in the above example), shUnit2 will look on its own for any functions that start with the string <literal>test</literal>, and adds those to an internal list of tests to execute. Once a list of test functions to be run has been determined, shunit2 will go to work.</para>
|
||||
|
||||
<para>Before any tests are executed, shUnit2 again looks for a function, this time one named <function>oneTimeSetUp()</function>. If it exists, it will be run. This function is normally used to setup the environment for all tests to be run. Things like creating directories for output or setting environment variables are good to place here. Just so you know, you can also declare a corresponding function named <function>oneTimeTearDown()</function> function that does the same thing, but once all the tests have been completed. It is good for removing temporary directories, etc.</para>
|
||||
|
||||
<para>shUnit2 is now ready to run tests. Before doing so though, it again looks for another function that might be declared, one named <function>setUp()</function>. If the function exists, it will be run before each test. It is good for resetting the environment so that each test starts with a clean slate. At this stage, the first test is finally run. The success of the test is recorded for a report that will be generated later. After the test is run, shUnit2 looks for a final function that might be declared, one named <function>tearDown()</function>. If it exists, it will be run after each test. It is a good place for cleaning up after each test, maybe doing things like removing files that were created, or removing directories. This set of steps, setUp() > test() > tearDown(), is repeated for all of the available tests.</para>
|
||||
|
||||
<para>Once all the work is done, shUnit2 will generate the nice report you saw above. A summary of all the successes and failures will be given so that you know how well your code is doing.</para>
|
||||
|
||||
<para>We should now try adding a test that fails. Change your unit test to look like this.</para>
|
||||
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
#! /bin/sh
|
||||
|
||||
testEquality()
|
||||
{
|
||||
assertEquals 1 1
|
||||
}
|
||||
|
||||
testPartyLikeItIs1999()
|
||||
{
|
||||
year=`date '+%Y'`
|
||||
assertEquals "It's not 1999 :-( This is ${year}." \
|
||||
'1999' "${year}"
|
||||
}
|
||||
|
||||
# load shunit2
|
||||
. ./shunit2
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
<para>So, what did you get? I guess it told you that this isn't 1999. Bummer, eh? Hopefully, you noticed a couple of things that were different about the second test. First, we added an optional message that the user will see if the assert fails. Second, we did comparisons of strings instead of integers as in the first test. It doesn't matter whether you are testing for equality of strings or integers. Both work equally well with shUnit2.</para>
|
||||
|
||||
<para>Hopefully, this is enough to get you started with unit testing. If you want a ton more examples, take a look at the tests provided with <ulink url="http://log4sh.sourceforge.net/">log4sh</ulink>. Examples of much more advanced usage can be seen there. shUnit2 was after all written to help with the unit testing problems that log4sh had.</para>
|
||||
</chapter>
|
@@ -1,85 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
$Id$
|
||||
vim: softtabstop=2 shiftwidth=2
|
||||
-->
|
||||
<!--
|
||||
|
||||
This document can be converted to HTML using the following commands:
|
||||
|
||||
$ java -cp xalan-2.6.0.jar \
|
||||
org.apache.xalan.xslt.Process -xml -in log4sh.xml -xsl tldp-one-page.xsl
|
||||
|
||||
$ xsltproc tldp-one-page.xsl log4sh.xml |xmllint -noblanks -
|
||||
|
||||
-->
|
||||
|
||||
<!DOCTYPE book
|
||||
PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd" [
|
||||
|
||||
<!ENTITY functions SYSTEM "functions.xml">
|
||||
<!ENTITY introduction SYSTEM "introduction.xml">
|
||||
<!ENTITY quickstart SYSTEM "quickstart.xml">
|
||||
|
||||
<!ENTITY myEmail "kate.ward@forestent.com">
|
||||
<!ENTITY isoDate "@@ISO_DATE@@">
|
||||
|
||||
<!ENTITY shunit2 "<command>shunit2</command>">
|
||||
]>
|
||||
|
||||
<book id="shUnit2" lang="en-US"><title>shUnit2</title>
|
||||
<bookinfo>
|
||||
<title>shUnit2 version 2.0.3</title>
|
||||
<authorgroup>
|
||||
<author>
|
||||
<firstname>Kate</firstname><surname>Ward</surname>
|
||||
<affiliation>
|
||||
<address>
|
||||
<email>&myEmail;</email>
|
||||
</address>
|
||||
</affiliation>
|
||||
</author>
|
||||
</authorgroup>
|
||||
|
||||
<!-- All dates specified in ISO "YYYY-MM-DD" format -->
|
||||
<pubdate>&isoDate;</pubdate>
|
||||
|
||||
<!-- TODO flush out like bookinfo in docbook-tdg -->
|
||||
|
||||
<!-- Most recent revision goes at the top; list in descending order -->
|
||||
<revhistory>
|
||||
<revision>
|
||||
<revnumber>2.0.3</revnumber>
|
||||
<date>2007-07-12</date>
|
||||
<authorinitials>Kate Ward <&myEmail;></authorinitials>
|
||||
</revision>
|
||||
|
||||
<revision>
|
||||
<revnumber>2.0.2</revnumber>
|
||||
<date>2007-04-22</date>
|
||||
<authorinitials>Kate Ward <&myEmail;></authorinitials>
|
||||
</revision>
|
||||
|
||||
<revision>
|
||||
<revnumber>2.0.1</revnumber>
|
||||
<date>2007-02-21</date>
|
||||
<authorinitials>Kate Ward <&myEmail;></authorinitials>
|
||||
</revision>
|
||||
|
||||
<revision>
|
||||
<revnumber>2.0.0</revnumber>
|
||||
<date>2007-02-20</date>
|
||||
<authorinitials>Kate Ward <&myEmail;></authorinitials>
|
||||
</revision>
|
||||
</revhistory>
|
||||
|
||||
<!-- Provide a good abstract; a couple of sentences is sufficient -->
|
||||
<abstract>
|
||||
<para><ulink url="http://sourceforge.net/projects/shunit2">shUnit2</ulink> is a unit test framework for Bourne based shell scripts, and it is designed to work in a similar manner to <ulink url="http://www.junit.org/">JUnit</ulink>, <ulink url="http://pyunit.sourceforge.net/">PyUnit</ulink>, etc.</para>
|
||||
</abstract>
|
||||
</bookinfo>
|
||||
|
||||
&introduction;
|
||||
&quickstart;
|
||||
&functions;
|
||||
</book>
|
@@ -1,799 +0,0 @@
|
||||
# $Id$
|
||||
# vim:syntax=sh:sts=2
|
||||
# vim:foldmethod=marker:foldmarker=/**,*/
|
||||
#
|
||||
#/**
|
||||
# <?xml version="1.0" encoding="UTF-8"?>
|
||||
# <s:shelldoc xmlns:s="http://www.forestent.com/projects/shelldoc/xsl/2005.0">
|
||||
# <s:header>
|
||||
# shUnit 2.0.4
|
||||
# Shell Unit Test Framework
|
||||
#
|
||||
# http://code.google.com/p/shunit2/
|
||||
#
|
||||
# written by Kate Ward <kate.ward@forestent.com>
|
||||
# released under the LGPL
|
||||
#
|
||||
# this module implements a xUnit based unit test framework similar to JUnit
|
||||
# </s:header>
|
||||
#*/
|
||||
|
||||
# shell flags for shunit:
|
||||
# u - treat unset variables as an error when performing parameter expansion
|
||||
__SHUNIT_SHELL_FLAGS='u'
|
||||
|
||||
# save the current set of shell flags, and then set some for ourselves
|
||||
__shunit_oldShellFlags="$-"
|
||||
for _shunit_shellFlag in `echo "${__SHUNIT_SHELL_FLAGS}" |sed 's/\(.\)/\1 /g'`
|
||||
do
|
||||
set -${_shunit_shellFlag}
|
||||
done
|
||||
unset _shunit_shellFlag
|
||||
|
||||
# constants
|
||||
|
||||
__SHUNIT_VERSION='2.0.4pre'
|
||||
|
||||
__SHUNIT_TRUE=0
|
||||
__SHUNIT_FALSE=1
|
||||
__SHUNIT_ERROR=2
|
||||
|
||||
__SHUNIT_ASSERT_MSG_PREFIX='ASSERT:'
|
||||
|
||||
for _su_const in `set |grep "^__SHUNIT_" |cut -d= -f1`; do
|
||||
readonly ${_su_const}
|
||||
done
|
||||
unset _su_const
|
||||
|
||||
# variables
|
||||
__shunit_suite=''
|
||||
|
||||
__shunit_testsPassed=0
|
||||
__shunit_testsFailed=0
|
||||
__shunit_testsTotal=0
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# assert functions
|
||||
#
|
||||
|
||||
#/**
|
||||
# <s:function group="asserts">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>assertEquals</function></funcdef>
|
||||
# <paramdef>string <parameter>[message]</parameter></paramdef>
|
||||
# <paramdef>string <parameter>expected</parameter></paramdef>
|
||||
# <paramdef>string <parameter>actual</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>Asserts that <emphasis>expected</emphasis> and
|
||||
# <emphasis>actual</emphasis> are equal to one another. The message is
|
||||
# optional.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
assertEquals()
|
||||
{
|
||||
_su_message=''
|
||||
if [ $# -eq 3 ]; then
|
||||
_su_message=$1
|
||||
shift
|
||||
fi
|
||||
_su_expected=${1:-}
|
||||
_su_actual=${2:-}
|
||||
|
||||
shunit_return=${__SHUNIT_TRUE}
|
||||
if [ "${_su_expected}" = "${_su_actual}" ]; then
|
||||
_shunit_testPassed
|
||||
else
|
||||
failNotEquals "${_su_message}" "${_su_expected}" "${_su_actual}"
|
||||
shunit_return=${__SHUNIT_FALSE}
|
||||
fi
|
||||
|
||||
unset _su_message _su_expected _su_actual
|
||||
return ${shunit_return}
|
||||
}
|
||||
|
||||
#/**
|
||||
# <s:function group="asserts">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>assertNull</function></funcdef>
|
||||
# <paramdef>string <parameter>[message]</parameter></paramdef>
|
||||
# <paramdef>string <parameter>value</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>Asserts that <emphasis>value</emphasis> is <literal>null</literal>,
|
||||
# or in shell terms a zero-length string. The message is optional.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
assertNull()
|
||||
{
|
||||
if [ $# -eq 2 ]; then
|
||||
assertTrue "$1" "[ -z '$2' ]"
|
||||
else
|
||||
assertTrue "[ -z '${1:-}' ]"
|
||||
fi
|
||||
}
|
||||
|
||||
#/**
|
||||
# <s:function group="asserts">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>assertNotNull</function></funcdef>
|
||||
# <paramdef>string <parameter>[message]</parameter></paramdef>
|
||||
# <paramdef>string <parameter>value</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>Asserts that <emphasis>value</emphasis> is <emphasis
|
||||
# role="strong">not</emphasis> <literal>null</literal>, or in shell terms not
|
||||
# a zero-length string. The message is optional.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
assertNotNull()
|
||||
{
|
||||
if [ $# -eq 2 ]; then
|
||||
assertTrue "$1" "[ -n '$2' ]"
|
||||
else
|
||||
assertTrue "[ -n '${1:-}' ]"
|
||||
fi
|
||||
}
|
||||
|
||||
#/**
|
||||
# <s:function group="asserts">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>assertSame</function></funcdef>
|
||||
# <paramdef>string <parameter>[message]</parameter></paramdef>
|
||||
# <paramdef>string <parameter>expected</parameter></paramdef>
|
||||
# <paramdef>string <parameter>actual</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>This function is functionally equivalent to
|
||||
# <function>assertEquals</function>.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
assertSame()
|
||||
{
|
||||
assertEquals "${@:-}"
|
||||
}
|
||||
|
||||
#/**
|
||||
# <s:function group="asserts">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>assertNotSame</function></funcdef>
|
||||
# <paramdef>string <parameter>[message]</parameter></paramdef>
|
||||
# <paramdef>string <parameter>unexpected</parameter></paramdef>
|
||||
# <paramdef>string <parameter>actual</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>Asserts that <emphasis>unexpected</emphasis> and
|
||||
# <emphasis>actual</emphasis> are <emphasis role="strong">not</emphasis>
|
||||
# equal to one another. The message is optional.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
assertNotSame()
|
||||
{
|
||||
_su_message=''
|
||||
if [ $# -eq 3 ]; then
|
||||
_su_message=$1
|
||||
shift
|
||||
fi
|
||||
_su_unexpected=${1:-}
|
||||
_su_actual=${2:-}
|
||||
|
||||
shunit_return=${__SHUNIT_TRUE}
|
||||
if [ "${_su_unexpected}" != "${_su_actual}" ]; then
|
||||
_shunit_testPassed
|
||||
else
|
||||
failSame "${_su_message}"
|
||||
shunit_return=${__SHUNIT_FALSE}
|
||||
fi
|
||||
|
||||
unset _su_message _su_unexpected _su_actual
|
||||
return ${shunit_return}
|
||||
}
|
||||
|
||||
#/**
|
||||
# <s:function group="asserts">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>assertTrue</function></funcdef>
|
||||
# <paramdef>string <parameter>[message]</parameter></paramdef>
|
||||
# <paramdef>string <parameter>condition</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>Asserts that a given shell test condition is true. The message is
|
||||
# optional.</para>
|
||||
# <para>Testing whether something is true or false is easy enough by using
|
||||
# the assertEquals/assertNotSame functions. Shell supports much more
|
||||
# complicated tests though, and a means to support them was needed. As such,
|
||||
# this function tests that conditions are true or false through evaluation
|
||||
# rather than just looking for a true or false.</para>
|
||||
# <funcsynopsis>
|
||||
# The following test will succeed: <funcsynopsisinfo>assertTrue "[ 34 -gt 23 ]"</funcsynopsisinfo>
|
||||
# The folloing test will fail with a message: <funcsynopsisinfo>assertTrue "test failed" "[ -r '/non/existant/file' ]"</funcsynopsisinfo>
|
||||
# </funcsynopsis>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
assertTrue()
|
||||
{
|
||||
_su_message=''
|
||||
if [ $# -eq 2 ]; then
|
||||
_su_message=$1
|
||||
shift
|
||||
fi
|
||||
_su_condition=${1:-}
|
||||
|
||||
shunit_return=${__SHUNIT_TRUE}
|
||||
|
||||
# see if condition is an integer, i.e. a return value
|
||||
_su_match=`expr "${_su_condition}" : '\([0-9]*\)'`
|
||||
if [ -z "${_su_condition}" ]; then
|
||||
# null condition
|
||||
shunit_return=${__SHUNIT_FALSE}
|
||||
elif [ "${_su_condition}" = "${_su_match}" ]; then
|
||||
# possible return value. treating 0 as true, and non-zero as false.
|
||||
[ ${_su_condition} -ne 0 ] && shunit_return=${__SHUNIT_FALSE}
|
||||
else
|
||||
# (hopefully) a condition
|
||||
( eval ${_su_condition} ) >/dev/null 2>&1
|
||||
[ $? -ne 0 ] && shunit_return=${__SHUNIT_FALSE}
|
||||
fi
|
||||
|
||||
# record the test
|
||||
if [ ${shunit_return} -eq ${__SHUNIT_TRUE} ]; then
|
||||
_shunit_testPassed
|
||||
else
|
||||
_shunit_testFailed "${_su_message}"
|
||||
fi
|
||||
|
||||
unset _su_message _su_condition _su_match
|
||||
return ${shunit_return}
|
||||
}
|
||||
|
||||
#/**
|
||||
# <s:function group="asserts">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>assertFalse</function></funcdef>
|
||||
# <paramdef>string <parameter>[message]</parameter></paramdef>
|
||||
# <paramdef>string <parameter>condition</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>Asserts that a given shell test condition is false. The message is
|
||||
# optional.</para>
|
||||
# <para>Testing whether something is true or false is easy enough by using
|
||||
# the assertEquals/assertNotSame functions. Shell supports much more
|
||||
# complicated tests though, and a means to support them was needed. As such,
|
||||
# this function tests that conditions are true or false through evaluation
|
||||
# rather than just looking for a true or false.</para>
|
||||
# <funcsynopsis>
|
||||
# The following test will succeed: <funcsynopsisinfo>assertFalse "[ 'apples' = 'oranges' ]"</funcsynopsisinfo>
|
||||
# The folloing test will fail with a message: <funcsynopsisinfo>assertFalse "test failed" "[ 1 -eq 1 -a 2 -eq 2 ]"</funcsynopsisinfo>
|
||||
# </funcsynopsis>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
assertFalse()
|
||||
{
|
||||
_su_message=''
|
||||
if [ $# -eq 2 ]; then
|
||||
_su_message=$1
|
||||
shift
|
||||
fi
|
||||
_su_condition=${1:-}
|
||||
|
||||
shunit_return=${__SHUNIT_TRUE}
|
||||
|
||||
# see if condition is an integer, i.e. a return value
|
||||
_su_match=`expr "${_su_condition}" : '\([0-9]*\)'`
|
||||
if [ -z "${_su_condition}" ]; then
|
||||
# null condition
|
||||
shunit_return=${__SHUNIT_FALSE}
|
||||
elif [ "${_su_condition}" = "${_su_match}" ]; then
|
||||
# possible return value. treating 0 as true, and non-zero as false.
|
||||
[ ${_su_condition} -eq 0 ] && shunit_return=${__SHUNIT_FALSE}
|
||||
else
|
||||
# (hopefully) a condition
|
||||
( eval ${_su_condition} ) >/dev/null 2>&1
|
||||
[ $? -eq 0 ] && shunit_return=${__SHUNIT_FALSE}
|
||||
fi
|
||||
|
||||
# record the test
|
||||
if [ ${shunit_return} -eq ${__SHUNIT_TRUE} ]; then
|
||||
_shunit_testPassed
|
||||
else
|
||||
_shunit_testFailed "${_su_message}"
|
||||
fi
|
||||
|
||||
unset _su_message _su_condition _su_match
|
||||
return ${shunit_return}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# failure functions
|
||||
#
|
||||
|
||||
#/**
|
||||
# <s:function group="failures">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>fail</function></funcdef>
|
||||
# <paramdef>string <parameter>[message]</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>Fails the test immediately, with the optional message.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
fail()
|
||||
{
|
||||
_su_message=${1:-}
|
||||
|
||||
_shunit_testFailed "${_su_message}"
|
||||
|
||||
unset _su_message
|
||||
}
|
||||
|
||||
#/**
|
||||
# <s:function group="failures">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>failNotEquals</function></funcdef>
|
||||
# <paramdef>string <parameter>[message]</parameter></paramdef>
|
||||
# <paramdef>string <parameter>unexpected</parameter></paramdef>
|
||||
# <paramdef>string <parameter>actual</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>Fails the test if <emphasis>unexpected</emphasis> and
|
||||
# <emphasis>actual</emphasis> are <emphasis role="strong">not</emphasis>
|
||||
# equal to one another. The message is optional.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
failNotEquals()
|
||||
{
|
||||
_su_message=''
|
||||
if [ $# -eq 3 ]; then
|
||||
_su_message=$1
|
||||
shift
|
||||
fi
|
||||
_su_unexpected=${1:-}
|
||||
_su_actual=${2:-}
|
||||
|
||||
_shunit_testFailed "${_su_message:+${_su_message} }expected:<${_su_unexpected}> but was:<${_su_actual}>"
|
||||
|
||||
unset _su_message _su_unexpected _su_actual
|
||||
}
|
||||
|
||||
#/**
|
||||
# <s:function group="failures">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>failSame</function></funcdef>
|
||||
# <paramdef>string <parameter>[message]</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>Indicate test failure because arguments were not the same. The
|
||||
# message is optional.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
failSame()
|
||||
{
|
||||
_su_message=${1:-}
|
||||
|
||||
_shunit_testFailed "${_su_message:+${_su_message} }expected not same"
|
||||
|
||||
unset _su_message
|
||||
}
|
||||
|
||||
#/**
|
||||
# <s:function group="failures">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>failNotSame</function></funcdef>
|
||||
# <paramdef>string <parameter>[message]</parameter></paramdef>
|
||||
# <paramdef>string <parameter>expected</parameter></paramdef>
|
||||
# <paramdef>string <parameter>actual</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>Fails the test if <emphasis>expected</emphasis> and
|
||||
# <emphasis>actual</emphasis> are equal to one another. The message is
|
||||
# optional.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
failNotSame()
|
||||
{
|
||||
failNotEquals "${@:-}"
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite functions
|
||||
#
|
||||
|
||||
#/**
|
||||
# <s:function group="suites">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>suite</function></funcdef>
|
||||
# <paramdef />
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>This function can be optionally overridden by the user in their test
|
||||
# suite.</para>
|
||||
# <para>If this function exists, it will be called when
|
||||
# <command>shunit2</command> is sourced. If it does not exist, shUnit2 will
|
||||
# search the parent script for all functions beginning with the word
|
||||
# <literal>test</literal>, and they will be added dynamically to the test
|
||||
# suite.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
# Note: see _shunit_mktempFunc() for actual implementation
|
||||
# suite() { :; }
|
||||
|
||||
#/**
|
||||
# <s:function group="suites">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>suite_addTest</function></funcdef>
|
||||
# <paramdef>string <parameter>function</parameter></paramdef>
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>This function adds a function name to the list of tests scheduled for
|
||||
# execution as part of this test suite. This function should only be called
|
||||
# from within the <function>suite()</function> function.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
suite_addTest()
|
||||
{
|
||||
_su_func=${1:-}
|
||||
|
||||
__shunit_suite="${__shunit_suite:+${__shunit_suite} }${_su_func}"
|
||||
|
||||
unset _su_func
|
||||
}
|
||||
|
||||
#/**
|
||||
# <s:function group="suites">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>oneTimeSetUp</function></funcdef>
|
||||
# <paramdef />
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>This function can be be optionally overridden by the user in their
|
||||
# test suite.</para>
|
||||
# <para>If this function exists, it will be called once before any tests are
|
||||
# run. It is useful to prepare a common environment for all tests.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
# Note: see _shunit_mktempFunc() for actual implementation
|
||||
# oneTimeSetUp() { :; }
|
||||
|
||||
#/**
|
||||
# <s:function group="suites">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>oneTimeTearDown</function></funcdef>
|
||||
# <paramdef />
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>This function can be be optionally overridden by the user in their
|
||||
# test suite.</para>
|
||||
# <para>If this function exists, it will be called once after all tests are
|
||||
# completed. It is useful to clean up the environment after all tests.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
# Note: see _shunit_mktempFunc() for actual implementation
|
||||
# oneTimeTearDown() { :; }
|
||||
|
||||
#/**
|
||||
# <s:function group="suites">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>setUp</function></funcdef>
|
||||
# <paramdef />
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>This function can be be optionally overridden by the user in their
|
||||
# test suite.</para>
|
||||
# <para>If this function exists, it will be called before each test is run.
|
||||
# It is useful to reset the environment before each test.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
# Note: see _shunit_mktempFunc() for actual implementation
|
||||
# setUp() { :; }
|
||||
|
||||
#/**
|
||||
# <s:function group="suites">
|
||||
# <entry align="right">
|
||||
# <emphasis>void</emphasis>
|
||||
# </entry>
|
||||
# <entry>
|
||||
# <funcsynopsis>
|
||||
# <funcprototype>
|
||||
# <funcdef><function>tearDown</function></funcdef>
|
||||
# <paramdef />
|
||||
# </funcprototype>
|
||||
# </funcsynopsis>
|
||||
# <para>This function can be be optionally overridden by the user in their
|
||||
# test suite.</para>
|
||||
# <para>If this function exists, it will be called after each test completes.
|
||||
# It is useful to clean up the environment after each test.</para>
|
||||
# </entry>
|
||||
# </s:function>
|
||||
#*/
|
||||
# Note: see _shunit_mktempFunc() for actual implementation
|
||||
# tearDown() { :; }
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# internal shUnit2 functions
|
||||
#
|
||||
|
||||
_shunit_cleanup()
|
||||
{
|
||||
name=$1
|
||||
|
||||
case ${name} in
|
||||
EXIT) signal=0 ;;
|
||||
INT) signal=2 ;;
|
||||
TERM) signal=15 ;;
|
||||
esac
|
||||
|
||||
# do our work
|
||||
rm -fr "${__shunit_tmpDir}"
|
||||
|
||||
# exit for all non-EXIT signals
|
||||
if [ ${name} != 'EXIT' ]; then
|
||||
echo "trapped and now handling the ${name} signal" >&2
|
||||
_shunit_generateReport
|
||||
# disable EXIT trap
|
||||
trap 0
|
||||
# add 128 to signal and exit
|
||||
exit `expr ${signal} + 128`
|
||||
fi
|
||||
}
|
||||
|
||||
_shunit_execSuite()
|
||||
{
|
||||
echo '#'
|
||||
echo '# Performing tests'
|
||||
echo '#'
|
||||
for _su_func in ${__shunit_suite}; do
|
||||
# execute the per-test setup function
|
||||
setUp
|
||||
|
||||
# execute the test
|
||||
echo "${_su_func}"
|
||||
eval ${_su_func}
|
||||
|
||||
# execute the per-test tear-down function
|
||||
tearDown
|
||||
done
|
||||
|
||||
unset _su_func
|
||||
}
|
||||
|
||||
_shunit_functionExists()
|
||||
{
|
||||
_su__func=$1
|
||||
type ${_su__func} 2>/dev/null |grep "is a function$" >/dev/null
|
||||
_su__return=$?
|
||||
unset _su__func
|
||||
return ${_su__return}
|
||||
}
|
||||
|
||||
_shunit_generateReport()
|
||||
{
|
||||
_su__awkPercent='{printf("%0.0f%%", $1*100/$2)}'
|
||||
if [ ${__shunit_testsTotal} -gt 0 ]; then
|
||||
_su__success=`echo ${__shunit_testsPassed} ${__shunit_testsTotal} |\
|
||||
awk "${_su__awkPercent}"`
|
||||
else
|
||||
_su__success=0
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
|
||||
#
|
||||
# Test report
|
||||
#
|
||||
tests passed: ${__shunit_testsPassed}
|
||||
tests failed: ${__shunit_testsFailed}
|
||||
tests total: ${__shunit_testsTotal}
|
||||
success rate: ${_su__success}
|
||||
EOF
|
||||
|
||||
unset _su__success
|
||||
}
|
||||
|
||||
# this function is a cross-platform temporary directory creation tool. not all
|
||||
# OSes have the mktemp function, so one is included here.
|
||||
_shunit_mktempDir()
|
||||
{
|
||||
# try the standard mktemp function
|
||||
( exec mktemp -dqt shunit.XXXXXX 2>/dev/null ) && return
|
||||
|
||||
# the standard mktemp didn't work. doing our own.
|
||||
if [ -r '/dev/urandom' -a -x '/usr/bin/od' ]; then
|
||||
_su__random=`/usr/bin/od -vAn -N4 -tx4 </dev/urandom \
|
||||
|sed 's/^[^0-9a-f]*//'`
|
||||
elif [ -n "${RANDOM:-}" ]; then
|
||||
# $RANDOM works
|
||||
_su__random=${RANDOM}${RANDOM}${RANDOM}$$
|
||||
else
|
||||
# $RANDOM doesn't work
|
||||
_su__date=`date '+%Y%m%d%H%M%S'`
|
||||
_su__random=`expr ${_su__date} / $$`
|
||||
fi
|
||||
|
||||
_su__tmpDir="${TMPDIR-/tmp}/shunit.${_su__random}"
|
||||
( umask 077 && mkdir "${_su__tmpDir}" ) || {
|
||||
echo 'shUnit:FATAL could not create temporary directory! exiting' >&2
|
||||
return ${__SHUNIT_ERROR}
|
||||
}
|
||||
|
||||
echo ${_su__tmpDir}
|
||||
unset _su__date _su__random _su__tmpDir
|
||||
}
|
||||
|
||||
# this function is here to work around issues in Cygwin
|
||||
_shunit_mktempFunc()
|
||||
{
|
||||
for _su__func in oneTimeSetUp oneTimeTearDown setUp tearDown suite; do
|
||||
_su__file="${__shunit_tmpDir}/${_su__func}"
|
||||
cat <<EOF >"${_su__file}"
|
||||
#! /bin/sh
|
||||
exit 0
|
||||
EOF
|
||||
chmod +x "${_su__file}"
|
||||
done
|
||||
|
||||
unset _su__file
|
||||
}
|
||||
|
||||
_shunit_testPassed()
|
||||
{
|
||||
__shunit_testsPassed=`expr ${__shunit_testsPassed} + 1`
|
||||
__shunit_testsTotal=`expr ${__shunit_testsTotal} + 1`
|
||||
}
|
||||
|
||||
_shunit_testFailed()
|
||||
{
|
||||
_su__msg=$1
|
||||
|
||||
__shunit_testsFailed=`expr ${__shunit_testsFailed} + 1`
|
||||
__shunit_testsTotal=`expr ${__shunit_testsTotal} + 1`
|
||||
echo "${__SHUNIT_ASSERT_MSG_PREFIX}${_su__msg}" >&2
|
||||
|
||||
unset _su__msg
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# main
|
||||
#
|
||||
|
||||
# create a temporary storage location
|
||||
__shunit_tmpDir=`_shunit_mktempDir` || exit ${__SHUNIT_ERROR}
|
||||
|
||||
# setup traps to clean up after ourselves
|
||||
trap '_shunit_cleanup EXIT' 0
|
||||
trap '_shunit_cleanup INT' 2
|
||||
trap '_shunit_cleanup TERM' 15
|
||||
|
||||
# create phantom functions to work around issues with Cygwin
|
||||
_shunit_mktempFunc
|
||||
PATH="${__shunit_tmpDir}:${PATH}"
|
||||
|
||||
# execute the oneTimeSetUp function (if it exists)
|
||||
#_shunit_functionExists oneTimeSetUp && oneTimeSetUp
|
||||
oneTimeSetUp
|
||||
|
||||
# deprecated: execute the suite function defined in the parent test script
|
||||
suite
|
||||
|
||||
# if no suite function was defined, dynamically build a list of functions
|
||||
if [ -z "${__shunit_suite}" ]; then
|
||||
funcs=`grep "^[ \t]*test[A-Za-z0-9_]* *()" $0 |sed 's/[^A-Za-z0-9_]//g'`
|
||||
for func in ${funcs}; do
|
||||
suite_addTest ${func}
|
||||
done
|
||||
fi
|
||||
|
||||
# execute the tests
|
||||
_shunit_execSuite
|
||||
|
||||
# execute the oneTimeTearDown function (if it exists)
|
||||
oneTimeTearDown
|
||||
|
||||
# generate report
|
||||
_shunit_generateReport
|
||||
|
||||
# restore the previous set of shell flags
|
||||
for _shunit_shellFlag in ${__SHUNIT_SHELL_FLAGS}; do
|
||||
echo ${__shunit_oldShellFlags} |grep ${_shunit_shellFlag} >/dev/null \
|
||||
|| set +${_shunit_shellFlag}
|
||||
done
|
||||
unset _shunit_shellFlag
|
||||
|
||||
#/**
|
||||
# </s:shelldoc>
|
||||
#*/
|
@@ -1,116 +0,0 @@
|
||||
#! /bin/sh
|
||||
# $Id: run-test-suite 432 2007-01-05 14:58:37Z sfsetse $
|
||||
|
||||
MY_NAME=`basename $0`
|
||||
MY_PATH=`dirname $0`
|
||||
|
||||
SHELLS='/bin/sh /bin/bash /bin/dash /bin/ksh /bin/pdksh'
|
||||
for f in test[A-Z]*; do
|
||||
[ -x "${f}" ] && TESTS="${TESTS:+${TESTS} }${f}"
|
||||
done
|
||||
|
||||
# load common unit test functions
|
||||
. "${MY_PATH}/test-functions.inc"
|
||||
|
||||
usage()
|
||||
{
|
||||
echo "usage: ${MY_NAME} [-e key=val ...] [-s shell(s)] [-t test(s)]"
|
||||
}
|
||||
|
||||
# process command line flags
|
||||
while getopts 'e:hs:t:' opt; do
|
||||
case ${opt} in
|
||||
e)
|
||||
key=`expr "${OPTARG}" : '\([^=]*\)='`
|
||||
val=`expr "${OPTARG}" : '[^=]*=\(.*\)'`
|
||||
if [ -z "${key}" -o -z "${val}" ]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
eval "${key}='${val}'"
|
||||
export ${key}
|
||||
env="${env:+${env} }${key}"
|
||||
;;
|
||||
h) usage; exit 0 ;;
|
||||
s) shells=${OPTARG} ;;
|
||||
t) tests=${OPTARG} ;;
|
||||
*) usage; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
shift `expr ${OPTIND} - 1`
|
||||
|
||||
# fill shells and/or tests
|
||||
shells=${shells:-${SHELLS}}
|
||||
tests=${tests:-${TESTS}}
|
||||
|
||||
# error checking
|
||||
if [ -z "${tests}" ]; then
|
||||
tf_error 'no tests found to run; exiting'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
#------------------------------------------------------------------------------
|
||||
# System data
|
||||
#
|
||||
|
||||
# test run info
|
||||
shells="${shells}"
|
||||
tests="${tests}"
|
||||
EOF
|
||||
for key in ${env}; do
|
||||
eval "echo \"${key}=\$${key}\""
|
||||
done
|
||||
echo
|
||||
|
||||
# output system data
|
||||
echo "# system info"
|
||||
echo "$ date"
|
||||
date
|
||||
|
||||
echo "$ uname -mprsv"
|
||||
uname -mprsv
|
||||
|
||||
#
|
||||
# run tests
|
||||
#
|
||||
|
||||
for shell in ${shells}; do
|
||||
echo
|
||||
|
||||
# check for existance of shell
|
||||
if [ ! -x ${shell} ]; then
|
||||
tf_warn "unable to run tests with the ${shell} shell"
|
||||
continue
|
||||
fi
|
||||
|
||||
cat <<EOF
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Running the test suite with ${shell}
|
||||
#
|
||||
EOF
|
||||
|
||||
case `basename ${shell}` in
|
||||
bash) echo; ${shell} --version; ;;
|
||||
dash) ;;
|
||||
ksh)
|
||||
version=`${shell} --version exit 2>&1`
|
||||
exitVal=$?
|
||||
if [ ${exitVal} -eq 2 ]; then
|
||||
echo
|
||||
echo "${version}"
|
||||
fi
|
||||
;;
|
||||
pdksh) ;;
|
||||
zsh) ;;
|
||||
esac
|
||||
|
||||
# execute the tests
|
||||
for suite in ${tests}; do
|
||||
suiteName=`expr "${suite}" : 'test\(.*\)'`
|
||||
echo
|
||||
echo "--- Executing the '${suiteName}' test suite ---" >&2
|
||||
( exec ${shell} ./${suite}; )
|
||||
done
|
||||
done
|
@@ -1,84 +0,0 @@
|
||||
# $Id: test-functions.inc 416 2007-01-04 00:50:14Z sfsetse $
|
||||
# vim:syntax=sh:sts=2
|
||||
|
||||
#
|
||||
# constants
|
||||
#
|
||||
|
||||
# configure debugging. set the DEBUG environment variable to any
|
||||
# non-empty value to enable debug output, or TRACE to enable trace
|
||||
# output.
|
||||
TRACE=${TRACE:+'tf_trace '}
|
||||
[ -n "${TRACE}" ] && DEBUG=1
|
||||
[ -z "${TRACE}" ] && TRACE=':'
|
||||
|
||||
DEBUG=${DEBUG:+'tf_debug '}
|
||||
[ -z "${DEBUG}" ] && DEBUG=':'
|
||||
|
||||
#
|
||||
# variables
|
||||
#
|
||||
|
||||
tf_RANDOM=0
|
||||
|
||||
#
|
||||
# functions
|
||||
#
|
||||
|
||||
# message functions
|
||||
tf_trace() { echo "${MY_NAME}:TRACE $@" >&2; }
|
||||
tf_debug() { echo "${MY_NAME}:DEBUG $@" >&2; }
|
||||
tf_info() { echo "${MY_NAME}:INFO $@" >&2; }
|
||||
tf_warn() { echo "${MY_NAME}:WARN $@" >&2; }
|
||||
tf_error() { echo "${MY_NAME}:ERROR $@" >&2; }
|
||||
tf_fatal() { echo "${MY_NAME}:FATAL $@" >&2; }
|
||||
|
||||
# generate a random number
|
||||
tf_generateRandom()
|
||||
{
|
||||
tfgr_random=${tf_RANDOM}
|
||||
|
||||
while [ "${tfgr_random}" = "${tf_RANDOM}" ]; do
|
||||
if [ -n "${RANDOM:-}" ]; then
|
||||
# $RANDOM works
|
||||
tfgr_random=${RANDOM}${RANDOM}${RANDOM}$$
|
||||
elif [ -r '/dev/urandom' ]; then
|
||||
tfgr_random=`od -vAn -N4 -tu4 </dev/urandom |sed 's/^[^0-9]*//'`
|
||||
else
|
||||
tfgr_date=`date '+%H%M%S'`
|
||||
tfgr_random=`expr ${tfgr_date} \* $$`
|
||||
unset tfgr_date
|
||||
fi
|
||||
[ "${tfgr_random}" = "${tf_RANDOM}" ] && sleep 1
|
||||
done
|
||||
|
||||
tf_RANDOM=${tfgr_random}
|
||||
unset tfgr_random
|
||||
}
|
||||
|
||||
# this section returns the data section from the specified section of a file. a
|
||||
# datasection is defined by a [header], one or more lines of data, and then a
|
||||
# blank line.
|
||||
tf_getDataSect()
|
||||
{
|
||||
tf_sgrep "\\[$1\\]" "$2" |sed '1d'
|
||||
}
|
||||
|
||||
# this function greps a section from a file. a section is defined as a group of
|
||||
# lines preceeded and followed by blank lines.
|
||||
tf_sgrep()
|
||||
{
|
||||
tf_pattern=$1
|
||||
shift
|
||||
|
||||
sed -e '/./{H;$!d;}' -e "x;/${tf_pattern}/"'!d;' $@ |sed '1d'
|
||||
|
||||
unset tf_pattern
|
||||
}
|
||||
|
||||
#
|
||||
# main
|
||||
#
|
||||
|
||||
${TRACE} 'trace output enabled'
|
||||
${DEBUG} 'debug output enabled'
|
@@ -1,242 +0,0 @@
|
||||
#! /bin/sh
|
||||
# $Id$
|
||||
# vim: expandtab
|
||||
# author: Kate Ward <kate.ward@forestent.com>
|
||||
#
|
||||
# Self-testing unit tests for shUnit2 asserts
|
||||
#
|
||||
|
||||
MSG='This is a test message'
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite tests
|
||||
#
|
||||
|
||||
commonEqualsSame()
|
||||
{
|
||||
fn=$1
|
||||
|
||||
msg='same, with message'
|
||||
rslt=`${fn} "${MSG}" 'x' 'x' 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='same'
|
||||
rslt=`${fn} 'x' 'x' 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='not same'
|
||||
rslt=`${fn} 'x' 'y' 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='null values'
|
||||
rslt=`${fn} '' '' 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='too few arguments'
|
||||
rslt=`${fn} 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
}
|
||||
|
||||
testAssertEquals()
|
||||
{
|
||||
commonEqualsSame 'assertEquals'
|
||||
}
|
||||
|
||||
testAssertSame()
|
||||
{
|
||||
commonEqualsSame 'assertSame'
|
||||
}
|
||||
|
||||
testAssertNotSame()
|
||||
{
|
||||
msg='not same, with message'
|
||||
rslt=`assertNotSame "${MSG}" 'x' 'y' 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='not same'
|
||||
rslt=`assertNotSame 'x' 'y' 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='same'
|
||||
rslt=`assertNotSame 'x' 'x' 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='null values'
|
||||
rslt=`assertNotSame '' '' 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='too few arguments'
|
||||
rslt=`assertNotSame 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
}
|
||||
|
||||
testAssertNull()
|
||||
{
|
||||
msg='null, with message'
|
||||
rslt=`assertNull "${MSG}" '' 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='null'
|
||||
rslt=`assertNull '' 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='not null'
|
||||
rslt=`assertNull 'x' 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='too few arguments'
|
||||
rslt=`assertNull 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
}
|
||||
|
||||
testAssertNotNull()
|
||||
{
|
||||
msg='not null, with message'
|
||||
rslt=`assertNotNull "${MSG}" 'x' 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='not null'
|
||||
rslt=`assertNotNull 'x' 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='null'
|
||||
rslt=`assertNotNull '' 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='too few arguments'
|
||||
rslt=`assertNotNull 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
}
|
||||
|
||||
testAssertTrue()
|
||||
{
|
||||
msg='true, with message'
|
||||
rslt=`assertTrue "${MSG}" 0 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='true'
|
||||
rslt=`assertTrue 0 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='true condition'
|
||||
rslt=`assertTrue "[ 0 -eq 0 ]" 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='false'
|
||||
rslt=`assertTrue 1 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='false condition'
|
||||
rslt=`assertTrue "[ 0 -eq 1 ]" 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='null value'
|
||||
rslt=`assertTrue '' 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='too few arguments'
|
||||
rslt=`assertTrue 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
}
|
||||
|
||||
testAssertFalse()
|
||||
{
|
||||
msg='false, with message'
|
||||
rslt=`assertFalse "${MSG}" 1 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='false'
|
||||
rslt=`assertFalse 1 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='false condition'
|
||||
rslt=`assertFalse "[ 0 -eq 1 ]" 2>&1`
|
||||
rtrn=$?
|
||||
assertSame "${msg}" '' "${rslt}"
|
||||
assertTrue "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='true'
|
||||
rslt=`assertFalse 0 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='true condition'
|
||||
rslt=`assertFalse "[ 0 -eq 0 ]" 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='null value'
|
||||
rslt=`assertFalse '' 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
|
||||
msg='too few arguments'
|
||||
rslt=`assertFalse 2>&1`
|
||||
rtrn=$?
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
assertFalse "${msg}; failure" ${rtrn}
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite functions
|
||||
#
|
||||
|
||||
# load and run shUnit2
|
||||
. ./shunit2
|
@@ -1,89 +0,0 @@
|
||||
#! /bin/sh
|
||||
# $Id$
|
||||
# vim: expandtab
|
||||
# author: Kate Ward <kate.ward@forestent.com>
|
||||
#
|
||||
# Self-testing unit tests for shUnit2 failures
|
||||
#
|
||||
|
||||
MSG='This is a test message'
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite tests
|
||||
#
|
||||
|
||||
commonNotEqualsSame()
|
||||
{
|
||||
fn=$1
|
||||
|
||||
msg='same, with message'
|
||||
rslt=`${fn} "${MSG}" 'x' 'x' 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
|
||||
msg='same'
|
||||
rslt=`${fn} 'x' 'x' 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
|
||||
msg='not same'
|
||||
rslt=`${fn} 'x' 'y' 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
|
||||
msg='null values'
|
||||
rslt=`${fn} '' '' 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
|
||||
msg='too few arguments'
|
||||
rslt=`${fn} 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
}
|
||||
|
||||
testFail()
|
||||
{
|
||||
msg='with message'
|
||||
rslt=`fail "${MSG}" 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
|
||||
msg='without message'
|
||||
rslt=`fail 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
}
|
||||
|
||||
testFailNotEquals()
|
||||
{
|
||||
commonNotEqualsSame 'failNotEquals'
|
||||
}
|
||||
|
||||
testFailSame()
|
||||
{
|
||||
msg='same, with message'
|
||||
rslt=`failSame "${MSG}" 'x' 'x' 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
|
||||
msg='same'
|
||||
rslt=`failSame 'x' 'x' 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
|
||||
msg='not same'
|
||||
rslt=`failSame 'x' 'y' 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
|
||||
msg='null values'
|
||||
rslt=`failSame '' '' 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
|
||||
msg='too few arguments'
|
||||
rslt=`failSame 2>&1`
|
||||
assertNotSame "${msg}" '' "${rslt}"
|
||||
}
|
||||
|
||||
testFailNotSame()
|
||||
{
|
||||
commonNotEqualsSame 'failNotSame'
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite functions
|
||||
#
|
||||
|
||||
# load and run shUnit2
|
||||
. ./shunit2
|
@@ -1,23 +0,0 @@
|
||||
#! /bin/sh
|
||||
# $Id$
|
||||
# vim: expandtab
|
||||
# author: Kate Ward <kate.ward@forestent.com>
|
||||
#
|
||||
# Self-testing unit tests for shUnit2 internal functions
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite tests
|
||||
#
|
||||
|
||||
testGenerateReport()
|
||||
{
|
||||
:
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite functions
|
||||
#
|
||||
|
||||
# load and run shUnit2
|
||||
. ./shunit2
|
@@ -1,23 +0,0 @@
|
||||
#! /bin/sh
|
||||
# $Id$
|
||||
# vim: expandtab
|
||||
# author: Kate Ward <kate.ward@forestent.com>
|
||||
#
|
||||
# Self-testing unit tests for shUnit2 suite functions
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite tests
|
||||
#
|
||||
|
||||
testAddTest()
|
||||
{
|
||||
:
|
||||
}
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# suite functions
|
||||
#
|
||||
|
||||
# load and run shUnit2
|
||||
. ./shunit2
|
@@ -1,12 +0,0 @@
|
||||
# $Id: gen_test_results.flags 145 2011-06-10 11:45:17Z kate.ward@forestent.com $
|
||||
# vim:et:ft=sh:sts=2:sw=2
|
||||
#
|
||||
# Copyright 2011 Kate Ward. All Rights Reserved.
|
||||
# Released under the LGPL (GNU Lesser General Public License)
|
||||
#
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
#
|
||||
# Flag definition overrides for the gen_test_results.sh script.
|
||||
#
|
||||
|
||||
DEFINE_string suite 'shunit2_test.sh' 'unit test suite' s
|
@@ -1,88 +0,0 @@
|
||||
#! /bin/sh
|
||||
# $Id: gen_test_results.sh 187 2013-01-15 00:01:51Z kate.ward@forestent.com $
|
||||
# vim:et:ft=sh:sts=2:sw=2
|
||||
#
|
||||
# Copyright 2008 Kate Ward. All Rights Reserved.
|
||||
# Released under the LGPL (GNU Lesser General Public License)
|
||||
#
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
#
|
||||
# This script runs the provided unit tests and sends the output to the
|
||||
# appropriate file.
|
||||
#
|
||||
|
||||
# treat unset variables as an error
|
||||
set -u
|
||||
|
||||
die()
|
||||
{
|
||||
[ $# -gt 0 ] && echo "error: $@" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
BASE_DIR="`dirname $0`/.."
|
||||
LIB_DIR="${BASE_DIR}/lib"
|
||||
|
||||
# load libraries
|
||||
. ${LIB_DIR}/shflags || die 'unable to load shflags library'
|
||||
. ${LIB_DIR}/shlib || die 'unable to load shlib library'
|
||||
. ${LIB_DIR}/versions || die 'unable to load versions library'
|
||||
|
||||
# redefining BASE_DIR now that we have the shlib functions
|
||||
BASE_DIR=`shlib_relToAbsPath "${BASE_DIR}"`
|
||||
BIN_DIR="${BASE_DIR}/bin"
|
||||
SRC_DIR="${BASE_DIR}/src"
|
||||
|
||||
os_name=`versions_osName |sed 's/ /_/g'`
|
||||
os_version=`versions_osVersion`
|
||||
|
||||
# load external flags
|
||||
. ${BIN_DIR}/gen_test_results.flags
|
||||
|
||||
# define flags
|
||||
DEFINE_boolean force false 'force overwrite' f
|
||||
DEFINE_string output_dir "`pwd`" 'output dir' d
|
||||
DEFINE_string output_file "${os_name}-${os_version}.txt" 'output file' o
|
||||
DEFINE_boolean dry_run false "supress logging to a file" n
|
||||
|
||||
main()
|
||||
{
|
||||
# determine output filename
|
||||
output="${FLAGS_output_dir:+${FLAGS_output_dir}/}${FLAGS_output_file}"
|
||||
output=`shlib_relToAbsPath "${output}"`
|
||||
|
||||
# checks
|
||||
[ -n "${FLAGS_suite:-}" ] || die 'suite flag missing'
|
||||
|
||||
if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} -a -f "${output}" ]; then
|
||||
if [ ${FLAGS_force} -eq ${FLAGS_TRUE} ]; then
|
||||
rm -f "${output}"
|
||||
else
|
||||
echo "not overwriting '${output}'" >&2
|
||||
exit ${FLAGS_ERROR}
|
||||
fi
|
||||
fi
|
||||
if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} ]; then
|
||||
touch "${output}" 2>/dev/null || die "unable to write to '${output}'"
|
||||
fi
|
||||
|
||||
# run tests
|
||||
(
|
||||
cd "${SRC_DIR}";
|
||||
if [ ${FLAGS_dry_run} -eq ${FLAGS_FALSE} ]; then
|
||||
./${FLAGS_suite} |tee "${output}"
|
||||
else
|
||||
./${FLAGS_suite}
|
||||
fi
|
||||
)
|
||||
|
||||
if [ ! ${FLAGS_dry_run} ]; then
|
||||
echo >&2
|
||||
echo "output written to '${output}'" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
FLAGS "$@" || exit $?
|
||||
[ ${FLAGS_help} -eq ${FALSE} ] || exit
|
||||
eval set -- "${FLAGS_ARGV}"
|
||||
main "${@:-}"
|
@@ -1,36 +0,0 @@
|
||||
#! /bin/sh
|
||||
# $Id$
|
||||
#
|
||||
# This is a simple implementation of the 'which' command for those OSes that
|
||||
# don't have one.
|
||||
#
|
||||
|
||||
true; TRUE=$?
|
||||
false; FALSE=$?
|
||||
|
||||
showAll=${FALSE}
|
||||
|
||||
# process command line flags
|
||||
while getopts 'a' opt; do
|
||||
case ${opt} in
|
||||
a) showAll=${TRUE}
|
||||
esac
|
||||
done
|
||||
shift `expr ${OPTIND} - 1`
|
||||
|
||||
# exit if no arguments were given
|
||||
[ $# -eq 0 ] && exit 1
|
||||
|
||||
command=$1
|
||||
|
||||
# search for command
|
||||
out=`echo "${PATH}" |sed "s/:/\n/g" |\
|
||||
while read path; do
|
||||
fullPath="${path}/${command}"
|
||||
if [ -x "${fullPath}" ]; then
|
||||
echo "${fullPath}"
|
||||
[ ${showAll} -eq ${FALSE} ] && break
|
||||
fi
|
||||
done`
|
||||
[ -z "${out}" ] && exit 1
|
||||
echo "${out}"
|
@@ -1,212 +0,0 @@
|
||||
====================
|
||||
shUnit2 2.1.x README
|
||||
====================
|
||||
|
||||
code.google.com
|
||||
===============
|
||||
|
||||
This project is stored on code.google.com as http://code.google.com/p/shunit2/.
|
||||
All releases as of 2.1.4 and full source are available there. Documentation is
|
||||
included as part of the source and each release. Source code is stored in
|
||||
Subversion and can be accessed using the following information.
|
||||
|
||||
Browse the code in a web browser:
|
||||
|
||||
- http://code.google.com/p/shunit2/source/browse
|
||||
- svn > trunk > source > 2.1
|
||||
|
||||
Check out the code locally ::
|
||||
|
||||
$ svn checkout http://shunit2.googlecode.com/svn/trunk/ shflags-read-only
|
||||
|
||||
|
||||
SourceForge
|
||||
===========
|
||||
|
||||
DEPRECATED
|
||||
|
||||
This project is stored on SourceForge as http://sf.net/projects/shunit2. The
|
||||
source code is stored in Subversion and can be accessed using the following
|
||||
information.
|
||||
|
||||
Check out the code locally ::
|
||||
|
||||
$ svn co https://shunit2.svn.sourceforge.net/svnroot/shunit2/trunk/source/2.1 shunit2
|
||||
|
||||
Browse the code in a web browser:
|
||||
|
||||
- http://shunit2.svn.sourceforge.net/viewvc/shunit2/trunk/source/2.1/
|
||||
- http://shunit2.svn.sourceforge.net/svnroot/shunit2/trunk/source/2.1/
|
||||
|
||||
|
||||
Making a release
|
||||
================
|
||||
|
||||
For these steps, it is assumed we are working with release 2.0.0.
|
||||
|
||||
Steps:
|
||||
|
||||
- write release notes
|
||||
- update version
|
||||
- finish changelog
|
||||
- check all the code in
|
||||
- tag the release
|
||||
- export the release
|
||||
- create tarball
|
||||
- md5sum the tarball and sign with gpg
|
||||
- update website
|
||||
- post to SourceForge and Freshmeat
|
||||
|
||||
Write Release Notes
|
||||
-------------------
|
||||
|
||||
This should be pretty self explanatory. Use one of the release notes from a
|
||||
previous release as an example.
|
||||
|
||||
The versions of the various platforms and shells are included when the
|
||||
master unit test script is run, or when ``bin/gen_test_results.sh`` is
|
||||
used. To determine the versions of the installed shells by hand, use the
|
||||
``lib/versions`` script.
|
||||
|
||||
Alternatively, do the following:
|
||||
|
||||
+-------+---------+-----------------------------------------------------------+
|
||||
| Shell | OS | Notes |
|
||||
+=======+=========+===========================================================+
|
||||
| bash | | ``$ bash --version`` |
|
||||
+-------+---------+-----------------------------------------------------------+
|
||||
| dash | Linux | ``$ dpkg -l |grep dash`` |
|
||||
+-------+---------+-----------------------------------------------------------+
|
||||
| ksh | | ``$ ksh --version`` |
|
||||
| | | -or- |
|
||||
| | | ``$ echo 'echo $KSH_VERSION' |ksh`` |
|
||||
| +---------+-----------------------------------------------------------+
|
||||
| | Cygwin | see pdksh |
|
||||
| +---------+-----------------------------------------------------------+
|
||||
| | Solaris | ``$ strings /usr/bin/ksh |grep 'Version'`` |
|
||||
+-------+---------+-----------------------------------------------------------+
|
||||
| pdksh | | ``$ strings /bin/pdksh |grep 'PD KSH'`` |
|
||||
| +---------+-----------------------------------------------------------+
|
||||
| | Cygwin | look in the downloaded Cygwin directory |
|
||||
+-------+---------+-----------------------------------------------------------+
|
||||
| sh | Solaris | not possible |
|
||||
+-------+---------+-----------------------------------------------------------+
|
||||
| zsh | | ``$ zsh --version`` |
|
||||
+-------+---------+-----------------------------------------------------------+
|
||||
|
||||
Update Version
|
||||
--------------
|
||||
|
||||
Edit ``src/shell/shunit2`` and change the version number in the comment, as well
|
||||
as in the ``SHUNIT_VERSION`` variable.
|
||||
|
||||
Finish Documentation
|
||||
--------------------
|
||||
|
||||
Make sure that any remaining changes get put into the ``CHANGES-X.X.txt`` file.
|
||||
|
||||
Finish writing the ``RELEASE_NOTES-X.X.X.txt``. If necessary, run it
|
||||
through the **fmt** command to make it pretty (hopefully it is already). ::
|
||||
|
||||
$ fmt -w 80 RELEASE_NOTES-2.0.0.txt >RELEASE_NOTES-2.0.0.txt.new
|
||||
$ mv RELEASE_NOTES-2.0.0.txt.new RELEASE_NOTES-2.0.0.txt
|
||||
|
||||
We want to have an up-to-date version of the documentation in the release, so
|
||||
we'd better build it. ::
|
||||
|
||||
$ pwd
|
||||
.../shunit2/source/2.1
|
||||
$ cd doc
|
||||
$ RST2HTML_OPTS='--stylesheet-path=rst2html.css'
|
||||
$ rst2html ${RST2HTML_OPTS} shunit2.txt >shunit2.html
|
||||
|
||||
Check In All the Code
|
||||
---------------------
|
||||
|
||||
This step is pretty self-explanatory ::
|
||||
|
||||
$ pwd
|
||||
.../shunit2/source/2.0
|
||||
$ svn ci -m "finalizing release"
|
||||
|
||||
Tag the Release
|
||||
---------------
|
||||
::
|
||||
|
||||
$ pwd
|
||||
.../shunit2/source
|
||||
$ ls
|
||||
2.0 2.1
|
||||
$ svn cp -m "Release 2.0.0" 2.0 https://shunit2.googlecode.com/svn/tags/source/2.0.0
|
||||
|
||||
Export the Release
|
||||
------------------
|
||||
::
|
||||
|
||||
$ pwd
|
||||
.../shunit2/builds
|
||||
$ svn export https://shunit2.googlecode.com/svn/tags/source/2.0.0 shunit2-2.0.0
|
||||
|
||||
Create Tarball
|
||||
--------------
|
||||
::
|
||||
|
||||
$ tar cfz ../releases/shunit2-2.0.0.tgz shunit2-2.0.0
|
||||
|
||||
Sign the Tarball with gpg
|
||||
-------------------------
|
||||
::
|
||||
|
||||
$ cd ../releases
|
||||
$ gpg --default-key kate.ward@forestent.com --detach-sign shunit2-2.0.0.tgz
|
||||
|
||||
Update Website
|
||||
--------------
|
||||
|
||||
Again, pretty self-explanatory. Make sure to copy the GPG signature file. Once
|
||||
done, make sure to tag the website so we can go back in time if needed. ::
|
||||
|
||||
$ pwd
|
||||
.../shunit2
|
||||
$ ls
|
||||
source website
|
||||
$ svn cp -m "Release 2.0.0" \
|
||||
website https://shunit2.googlecode.com/svn/tags/website/20060916
|
||||
|
||||
Now, update the website. It too is held in Subversion, so **ssh** into the web
|
||||
server and use ``svn up`` to grab the latest version.
|
||||
|
||||
Post to code.google.com and Freshmeat
|
||||
-------------------------------------
|
||||
|
||||
- http://code.google.com/p/shunit2/
|
||||
- http://freshmeat.net/
|
||||
|
||||
|
||||
Related Documentation
|
||||
=====================
|
||||
|
||||
Docbook:
|
||||
http://www.docbook.org/
|
||||
|
||||
Docbook XML
|
||||
docbook-xml-4.4.zip:
|
||||
http://www.docbook.org/xml/4.4/docbook-xml-4.4.zip
|
||||
http://www.oasis-open.org/docbook/xml/4.4/docbook-xml-4.4.zip
|
||||
docbook-xml-4.5.zip:
|
||||
http://www.docbook.org/xml/4.5/docbook-xml-4.5.zip
|
||||
Docbook XSL
|
||||
docbook-xsl-1.71.0.tar.bz2:
|
||||
http://prdownloads.sourceforge.net/docbook/docbook-xsl-1.71.0.tar.bz2?download
|
||||
docbook-xsl-1.71.1.tar.bz2:
|
||||
http://downloads.sourceforge.net/docbook/docbook-xsl-1.71.1.tar.bz2?use_mirror=puzzle
|
||||
JUnit:
|
||||
http://www.junit.org/
|
||||
reStructuredText:
|
||||
http://docutils.sourceforge.net/docs/user/rst/quickstart.html
|
||||
|
||||
.. generate HTML using rst2html from Docutils of
|
||||
.. http://docutils.sourceforge.net/
|
||||
..
|
||||
.. vim:fileencoding=latin1:ft=rst:spell:tw=80
|
||||
.. $Revision$
|
@@ -1,74 +0,0 @@
|
||||
Coding Standards
|
||||
================
|
||||
|
||||
Variable and Function Names
|
||||
---------------------------
|
||||
|
||||
All shUnit2 specific constants, variables, and functions will be prefixed
|
||||
appropriately with 'shunit'. This is to distinguish usage in the shUnit2 code
|
||||
from users own scripts so that the shell name space remains predictable to
|
||||
users. The exceptions here are the standard ``assertEquals``, etc. functions.
|
||||
|
||||
All non-builtin constants and variables will be surrouned with squiggle
|
||||
brackets, e.g. '${shunit_someVariable}' to improve code readability.
|
||||
|
||||
Due to some shells not supporting local variables in functions, care in the
|
||||
naming and use of variables, both public and private, is very important.
|
||||
Accidental overriding of the variables can occur easily if care is not taken as
|
||||
all variables are technically global variables in some shells.
|
||||
|
||||
+----------------------------------+---------------------------+
|
||||
| *type* | *sample* |
|
||||
+==================================+===========================+
|
||||
| global public constant | ``SHUNIT_TRUE`` |
|
||||
+----------------------------------+---------------------------+
|
||||
| global private constant | ``__SHUNIT_SHELL_FLAGS`` |
|
||||
+----------------------------------+---------------------------+
|
||||
| global public variable | not used |
|
||||
+----------------------------------+---------------------------+
|
||||
| global private variable | ``__shunit_someVariable`` |
|
||||
+----------------------------------+---------------------------+
|
||||
| global macro | ``_SHUNIT_SOME_MACRO_`` |
|
||||
+----------------------------------+---------------------------+
|
||||
| public function | ``assertEquals`` |
|
||||
+----------------------------------+---------------------------+
|
||||
| public function, local variable | ``shunit_someVariable_`` |
|
||||
+----------------------------------+---------------------------+
|
||||
| private function | ``_shunit_someFunction`` |
|
||||
+----------------------------------+---------------------------+
|
||||
| private function, local variable | ``_shunit_someVariable_`` |
|
||||
+----------------------------------+---------------------------+
|
||||
|
||||
Where it makes sense, variables can have the first letter of the second and
|
||||
later words capitalized. For example, the local variable name for the total
|
||||
number of test cases seen might be ``shunit_totalTestsSeen_``.
|
||||
|
||||
Local Variable Cleanup
|
||||
----------------------
|
||||
|
||||
As many shells do not support local variables, no support for cleanup of
|
||||
variables is present either. As such, all variables local to a function must be
|
||||
cleared up with the ``unset`` command at the end of each function.
|
||||
|
||||
Indentation
|
||||
-----------
|
||||
|
||||
Code block indentation is two (2) spaces, and tabs may not be used. ::
|
||||
|
||||
if [ -z 'some string' ]; then
|
||||
someFunction
|
||||
fi
|
||||
|
||||
Lines of code should be no longer than 80 characters unless absolutely
|
||||
necessary. When lines are wrapped using the backslash character '\', subsequent
|
||||
lines should be indented with four (4) spaces so as to differentiate from the
|
||||
standard spacing of two characters. Tabs may *not* be used. ::
|
||||
|
||||
for x in some set of very long set of arguments that make for a very long \
|
||||
that extends much too long for one line
|
||||
do
|
||||
echo ${x}
|
||||
done
|
||||
|
||||
.. vim:fileencoding=latin1:ft=rst:spell:tw=80
|
||||
.. $Revision$
|
@@ -1,14 +0,0 @@
|
||||
The original author of shunit2 is Kate Ward. The following people have
|
||||
contributed in some way or another to shunit2.
|
||||
|
||||
Bryan Larsen
|
||||
Kevin Van Horn
|
||||
Maciej Bliziński
|
||||
Mario Sparada
|
||||
Mathias Goldau
|
||||
Richard Jensen
|
||||
Rob Holland
|
||||
Rocky Bernstein
|
||||
wood4321 (of code.google.com)
|
||||
|
||||
$Revision$
|
@@ -1,502 +0,0 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
@@ -1,292 +0,0 @@
|
||||
/*
|
||||
:Author: David Goodger
|
||||
:Contact: goodger@users.sourceforge.net
|
||||
:Date: $Date: 2007-04-11 11:48:16 +0100 (Wed, 11 Apr 2007) $
|
||||
:Revision: $Revision: 2791 $
|
||||
:Copyright: This stylesheet has been placed in the public domain.
|
||||
:Modified by: Kate Ward <kate.ward@forestent.com>
|
||||
|
||||
Default cascading style sheet for the HTML output of Docutils.
|
||||
|
||||
See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to
|
||||
customize this style sheet.
|
||||
*/
|
||||
|
||||
/* used to remove borders from tables and images */
|
||||
.borderless, table.borderless td, table.borderless th {
|
||||
border: 0 }
|
||||
|
||||
table.borderless td, table.borderless th {
|
||||
/* Override padding for "table.docutils td" with "! important".
|
||||
The right padding separates the table cells. */
|
||||
padding: 0 0.5em 0 0 ! important }
|
||||
|
||||
.first {
|
||||
/* Override more specific margin styles with "! important". */
|
||||
margin-top: 0 ! important }
|
||||
|
||||
.last, .with-subtitle {
|
||||
margin-bottom: 0 ! important }
|
||||
|
||||
.hidden {
|
||||
display: none }
|
||||
|
||||
a.toc-backref {
|
||||
text-decoration: none ;
|
||||
color: black }
|
||||
|
||||
blockquote.epigraph {
|
||||
margin: 2em 5em ; }
|
||||
|
||||
dl.docutils dd {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
/* Uncomment (and remove this text!) to get bold-faced definition list terms
|
||||
dl.docutils dt {
|
||||
font-weight: bold }
|
||||
*/
|
||||
|
||||
div.abstract {
|
||||
margin: 2em 5em }
|
||||
|
||||
div.abstract p.topic-title {
|
||||
font-weight: bold ;
|
||||
text-align: center }
|
||||
|
||||
div.admonition, div.attention, div.caution, div.danger, div.error,
|
||||
div.hint, div.important, div.note, div.tip, div.warning {
|
||||
margin: 2em ;
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.admonition p.admonition-title, div.hint p.admonition-title,
|
||||
div.important p.admonition-title, div.note p.admonition-title,
|
||||
div.tip p.admonition-title {
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
div.attention p.admonition-title, div.caution p.admonition-title,
|
||||
div.danger p.admonition-title, div.error p.admonition-title,
|
||||
div.warning p.admonition-title {
|
||||
color: red ;
|
||||
font-weight: bold ;
|
||||
font-family: sans-serif }
|
||||
|
||||
/* Uncomment (and remove this text!) to get reduced vertical space in
|
||||
compound paragraphs.
|
||||
div.compound .compound-first, div.compound .compound-middle {
|
||||
margin-bottom: 0.5em }
|
||||
|
||||
div.compound .compound-last, div.compound .compound-middle {
|
||||
margin-top: 0.5em }
|
||||
*/
|
||||
|
||||
div.dedication {
|
||||
margin: 2em 5em ;
|
||||
text-align: center ;
|
||||
font-style: italic }
|
||||
|
||||
div.dedication p.topic-title {
|
||||
font-weight: bold ;
|
||||
font-style: normal }
|
||||
|
||||
div.figure {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em }
|
||||
|
||||
div.footer, div.header {
|
||||
clear: both;
|
||||
font-size: smaller }
|
||||
|
||||
div.line-block {
|
||||
display: block ;
|
||||
margin-top: 1em ;
|
||||
margin-bottom: 1em }
|
||||
|
||||
div.line-block div.line-block {
|
||||
margin-top: 0 ;
|
||||
margin-bottom: 0 ;
|
||||
margin-left: 1.5em }
|
||||
|
||||
div.sidebar {
|
||||
margin-left: 1em ;
|
||||
border: medium outset ;
|
||||
padding: 1em ;
|
||||
background-color: #ffffee ;
|
||||
width: 40% ;
|
||||
float: right ;
|
||||
clear: right }
|
||||
|
||||
div.sidebar p.rubric {
|
||||
font-family: sans-serif ;
|
||||
font-size: medium }
|
||||
|
||||
div.system-messages {
|
||||
margin: 5em }
|
||||
|
||||
div.system-messages h1 {
|
||||
color: red }
|
||||
|
||||
div.system-message {
|
||||
border: medium outset ;
|
||||
padding: 1em }
|
||||
|
||||
div.system-message p.system-message-title {
|
||||
color: red ;
|
||||
font-weight: bold }
|
||||
|
||||
div.topic {
|
||||
margin: 2em }
|
||||
|
||||
h1.section-subtitle, h2.section-subtitle, h3.section-subtitle,
|
||||
h4.section-subtitle, h5.section-subtitle, h6.section-subtitle {
|
||||
margin-top: 0.4em }
|
||||
|
||||
h1.title {
|
||||
text-align: center }
|
||||
|
||||
h2.subtitle {
|
||||
text-align: center }
|
||||
|
||||
hr.docutils {
|
||||
width: 75% }
|
||||
|
||||
img.align-left {
|
||||
clear: left }
|
||||
|
||||
img.align-right {
|
||||
clear: right }
|
||||
|
||||
ol.simple, ul.simple {
|
||||
margin-bottom: 1em }
|
||||
|
||||
ol.arabic {
|
||||
list-style: decimal }
|
||||
|
||||
ol.loweralpha {
|
||||
list-style: lower-alpha }
|
||||
|
||||
ol.upperalpha {
|
||||
list-style: upper-alpha }
|
||||
|
||||
ol.lowerroman {
|
||||
list-style: lower-roman }
|
||||
|
||||
ol.upperroman {
|
||||
list-style: upper-roman }
|
||||
|
||||
p.attribution {
|
||||
text-align: right ;
|
||||
margin-left: 50% }
|
||||
|
||||
p.caption {
|
||||
font-style: italic }
|
||||
|
||||
p.credits {
|
||||
font-style: italic ;
|
||||
font-size: smaller }
|
||||
|
||||
p.label {
|
||||
white-space: nowrap }
|
||||
|
||||
p.rubric {
|
||||
font-weight: bold ;
|
||||
font-size: larger ;
|
||||
color: maroon ;
|
||||
text-align: center }
|
||||
|
||||
p.sidebar-title {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold ;
|
||||
font-size: larger }
|
||||
|
||||
p.sidebar-subtitle {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
p.topic-title {
|
||||
font-weight: bold }
|
||||
|
||||
pre.address {
|
||||
margin-bottom: 0 ;
|
||||
margin-top: 0 ;
|
||||
font-family: serif ;
|
||||
font-size: 100% }
|
||||
|
||||
pre.literal-block, pre.doctest-block {
|
||||
margin-left: 2em ;
|
||||
margin-right: 2em ;
|
||||
background-color: #eeeeee }
|
||||
|
||||
span.classifier {
|
||||
font-family: sans-serif ;
|
||||
font-style: oblique }
|
||||
|
||||
span.classifier-delimiter {
|
||||
font-family: sans-serif ;
|
||||
font-weight: bold }
|
||||
|
||||
span.interpreted {
|
||||
font-family: sans-serif }
|
||||
|
||||
span.option {
|
||||
white-space: nowrap }
|
||||
|
||||
span.pre {
|
||||
white-space: pre }
|
||||
|
||||
span.problematic {
|
||||
color: red }
|
||||
|
||||
span.section-subtitle {
|
||||
/* font-size relative to parent (h1..h6 element) */
|
||||
font-size: 80% }
|
||||
|
||||
table.citation {
|
||||
border-left: solid 1px gray;
|
||||
margin-left: 1px }
|
||||
|
||||
table.docinfo {
|
||||
margin: 2em 4em }
|
||||
|
||||
/*
|
||||
table.docutils {
|
||||
margin-top: 0.5em ;
|
||||
margin-bottom: 0.5em }
|
||||
*/
|
||||
|
||||
table.footnote {
|
||||
border-left: solid 1px black;
|
||||
margin-left: 1px ;
|
||||
font-size: 80% }
|
||||
}
|
||||
|
||||
table.docutils td, table.docutils th,
|
||||
table.docinfo td, table.docinfo th {
|
||||
padding-left: 0.5em ;
|
||||
padding-right: 0.5em ;
|
||||
vertical-align: top }
|
||||
|
||||
table.docutils th.field-name, table.docinfo th.docinfo-name {
|
||||
font-weight: bold ;
|
||||
text-align: left ;
|
||||
white-space: nowrap ;
|
||||
padding-left: 0 }
|
||||
|
||||
h1 tt.docutils, h2 tt.docutils, h3 tt.docutils,
|
||||
h4 tt.docutils, h5 tt.docutils, h6 tt.docutils {
|
||||
font-size: 100% }
|
||||
|
||||
/*
|
||||
tt.docutils {
|
||||
background-color: #eeeeee }
|
||||
*/
|
||||
|
||||
ul.auto-toc {
|
||||
list-style-type: none }
|
||||
|
||||
/* customizations by kward */
|
||||
|
||||
h1 { font-size: 133%; border-top:1px solid #CCCCFF; }
|
||||
h1.title { font-size: 150%; border-top:0px; padding-top: 1em; }
|
||||
/* div.document { font-size: 90% } */
|
@@ -1,16 +0,0 @@
|
||||
#! /bin/sh
|
||||
# file: examples/lineno_test.sh
|
||||
|
||||
testLineNo()
|
||||
{
|
||||
# this assert will have line numbers included (e.g. "ASSERT:[123] ...") if
|
||||
# they are supported.
|
||||
echo "_ASSERT_EQUALS_ macro value: ${_ASSERT_EQUALS_}"
|
||||
${_ASSERT_EQUALS_} 'not equal' 1 2
|
||||
|
||||
# this assert will not have line numbers included (e.g. "ASSERT: ...")
|
||||
assertEquals 'not equal' 1 2
|
||||
}
|
||||
|
||||
# load shunit2
|
||||
. ../src/shunit2
|
@@ -1,17 +0,0 @@
|
||||
#! /bin/sh
|
||||
# file: examples/party_test.sh
|
||||
|
||||
testEquality()
|
||||
{
|
||||
assertEquals 1 1
|
||||
}
|
||||
|
||||
testPartyLikeItIs1999()
|
||||
{
|
||||
year=`date '+%Y'`
|
||||
assertEquals "It's not 1999 :-(" \
|
||||
'1999' "${year}"
|
||||
}
|
||||
|
||||
# load shunit2
|
||||
. ../src/shunit2
|
@@ -1,239 +0,0 @@
|
||||
#! /bin/sh
|
||||
# $Id: versions 175 2013-01-14 22:16:01Z kate.ward@forestent.com $
|
||||
# vim:et:ft=sh:sts=2:sw=2
|
||||
#
|
||||
# Copyright 2008 Kate Ward. All Rights Reserved.
|
||||
# Released under the LGPL (GNU Lesser General Public License)
|
||||
#
|
||||
# Author: kate.ward@forestent.com (Kate Ward)
|
||||
#
|
||||
# This library provides reusable functions that determine actual names and
|
||||
# versions of installed shells and the OS. The library can also be run as a
|
||||
# script if set execuatable.
|
||||
|
||||
ARGV0=`basename "$0"`
|
||||
LSB_RELEASE='/etc/lsb-release'
|
||||
VERSIONS_SHELLS="/bin/bash /bin/dash /bin/ksh /bin/pdksh /bin/sh /bin/zsh"
|
||||
|
||||
TRUE=0
|
||||
FALSE=1
|
||||
ERROR=2
|
||||
|
||||
UNAME_R=`uname -r`
|
||||
UNAME_S=`uname -s`
|
||||
|
||||
__versions_haveStrings=${ERROR}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# functions
|
||||
#
|
||||
|
||||
versions_osName()
|
||||
{
|
||||
os_name_='unrecognized'
|
||||
os_system_=${UNAME_S}
|
||||
case ${os_system_} in
|
||||
CYGWIN_NT-*) os_name_='Cygwin' ;;
|
||||
Darwin) os_name_='Mac OS X' ;;
|
||||
FreeBSD) os_name_='FreeBSD' ;;
|
||||
Linux) os_name_='Linux' ;;
|
||||
SunOS)
|
||||
if grep 'OpenSolaris' /etc/release >/dev/null; then
|
||||
os_name_='OpenSolaris'
|
||||
else
|
||||
os_name_='Solaris'
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
echo ${os_name_}
|
||||
unset os_name_ os_system_
|
||||
}
|
||||
|
||||
versions_osVersion()
|
||||
{
|
||||
os_version_='unrecognized'
|
||||
os_system_=${UNAME_S}
|
||||
os_release_=${UNAME_R}
|
||||
case ${os_system_} in
|
||||
CYGWIN_NT-*)
|
||||
os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]\.[0-9]*\).*'`
|
||||
;;
|
||||
Darwin)
|
||||
major_='10'
|
||||
sub_=`echo ${os_release_} |sed 's/^[0-9]*\.\([0-9]*\)\.[0-9]*$/\1/'`
|
||||
case ${os_release_} in
|
||||
8.*) minor_='4' ;;
|
||||
9.*) minor_='5' ;;
|
||||
10.*) minor_='6' ;;
|
||||
11.*) minor_='7' ;;
|
||||
12.*) minor_='8' ;;
|
||||
*) minor_='X'; sub_='X' ;;
|
||||
esac
|
||||
os_version_="${major_}.${minor_}.${sub_}"
|
||||
;;
|
||||
FreeBSD)
|
||||
os_version_=`expr "${os_release_}" : '\([0-9]*\.[0-9]*\)-.*'`
|
||||
;;
|
||||
Linux)
|
||||
if [ -r "${LSB_RELEASE}" ]; then
|
||||
if grep -q 'DISTRIB_ID=Ubuntu' "${LSB_RELEASE}"; then
|
||||
os_version_=`cat "${LSB_RELEASE}" \
|
||||
|awk -F= '$1~/DISTRIB_DESCRIPTION/{print $2}' \
|
||||
|sed 's/"//g;s/ /-/g'`
|
||||
fi
|
||||
elif [ -r '/etc/redhat-release' ]; then
|
||||
os_version_=`cat /etc/redhat-release`
|
||||
fi
|
||||
;;
|
||||
SunOS)
|
||||
if grep 'OpenSolaris' /etc/release >/dev/null; then
|
||||
os_version_=`grep 'OpenSolaris' /etc/release |awk '{print $2"("$3")"}'`
|
||||
else
|
||||
major_=`echo ${os_release_} |sed 's/[0-9]*\.\([0-9]*\)/\1/'`
|
||||
minor_=`grep Solaris /etc/release |sed 's/[^u]*\(u[0-9]*\).*/\1/'`
|
||||
os_version_="${major_}${minor_}"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
echo ${os_version_}
|
||||
unset os_name_ os_release_ os_version_ major_ minor_ sub_
|
||||
}
|
||||
|
||||
versions_shellVersion()
|
||||
{
|
||||
shell_=$1
|
||||
|
||||
if [ ! -x "${shell_}" ]; then
|
||||
echo 'not installed'
|
||||
return
|
||||
fi
|
||||
|
||||
version_=''
|
||||
case ${shell_} in
|
||||
*/sh)
|
||||
# TODO(kward): fix this
|
||||
## this could be one of any number of shells. try until one fits.
|
||||
#version_=`versions_shell_bash ${shell_}`
|
||||
## dash cannot be self determined yet
|
||||
#[ -z "${version_}" ] && version_=`versions_shell_ksh ${shell_}`
|
||||
## pdksh is covered in versions_shell_ksh()
|
||||
#[ -z "${version_}" ] && version_=`versions_shell_zsh ${shell_}`
|
||||
;;
|
||||
*/bash) version_=`versions_shell_bash ${shell_}` ;;
|
||||
*/dash)
|
||||
# simply assuming Ubuntu Linux until somebody comes up with a better
|
||||
# test. the following test will return an empty string if dash is not
|
||||
# installed.
|
||||
version_=`versions_shell_dash`
|
||||
;;
|
||||
*/ksh) version_=`versions_shell_ksh ${shell_}` ;;
|
||||
*/pdksh) version_=`versions_shell_pdksh ${shell_}` ;;
|
||||
*/zsh) version_=`versions_shell_zsh ${shell_}` ;;
|
||||
*) version_='invalid'
|
||||
esac
|
||||
|
||||
echo ${version_:-unknown}
|
||||
unset shell_ version_
|
||||
}
|
||||
|
||||
versions_shell_bash()
|
||||
{
|
||||
$1 --version 2>&1 |grep 'GNU bash' |sed 's/.*version \([^ ]*\).*/\1/'
|
||||
}
|
||||
|
||||
versions_shell_dash()
|
||||
{
|
||||
eval dpkg >/dev/null 2>&1
|
||||
[ $? -eq 127 ] && return # return if dpkg not found
|
||||
|
||||
dpkg -l |grep ' dash ' |awk '{print $3}'
|
||||
}
|
||||
|
||||
versions_shell_ksh()
|
||||
{
|
||||
versions_shell_=$1
|
||||
|
||||
# try a few different ways to figure out the version
|
||||
versions_version_=`${versions_shell_} --version : 2>&1`
|
||||
if [ $? -eq 0 ]; then
|
||||
versions_version_=`echo "${versions_version_}" \
|
||||
|sed 's/.*\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\).*/\1/'`
|
||||
else
|
||||
versions_version_=''
|
||||
fi
|
||||
|
||||
if [ -z "${versions_version_}" ]; then
|
||||
_versions_have_strings
|
||||
versions_version_=`strings ${versions_shell_} 2>&1 \
|
||||
|grep Version \
|
||||
|sed 's/^.*Version \(.*\)$/\1/;s/ s+ \$$//;s/ /-/g'`
|
||||
fi
|
||||
|
||||
if [ -z "${versions_version_}" ]; then
|
||||
versions_version_=`versions_shell_pdksh ${versions_shell_}`
|
||||
fi
|
||||
|
||||
echo ${versions_version_}
|
||||
unset versions_shell_ versions_version_
|
||||
}
|
||||
|
||||
versions_shell_pdksh()
|
||||
{
|
||||
_versions_have_strings
|
||||
strings $1 2>&1 \
|
||||
|grep 'PD KSH' \
|
||||
|sed -e 's/.*PD KSH \(.*\)/\1/;s/ /-/g'
|
||||
}
|
||||
|
||||
versions_shell_zsh()
|
||||
{
|
||||
versions_shell_=$1
|
||||
|
||||
# try a few different ways to figure out the version
|
||||
versions_version_=`echo 'echo ${ZSH_VERSION}' |${versions_shell_}`
|
||||
|
||||
if [ -z "${versions_version_}" ]; then
|
||||
versions_version_=`${versions_shell_} --version 2>&1 |awk '{print $2}'`
|
||||
fi
|
||||
|
||||
echo ${versions_version_}
|
||||
unset versions_shell_ versions_version_
|
||||
}
|
||||
|
||||
# Determine if the 'strings' binary installed.
|
||||
_versions_have_strings()
|
||||
{
|
||||
[ ${__versions_haveStrings} -ne ${ERROR} ] && return
|
||||
eval strings /dev/null >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
__versions_haveStrings=${TRUE}
|
||||
else
|
||||
echo 'WARN: strings not installed. try installing binutils?' >&2
|
||||
__versions_haveStrings=${FALSE}
|
||||
fi
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# main
|
||||
#
|
||||
|
||||
versions_main()
|
||||
{
|
||||
# treat unset variables as an error
|
||||
set -u
|
||||
|
||||
os_name=`versions_osName`
|
||||
os_version=`versions_osVersion`
|
||||
echo "os: ${os_name} version: ${os_version}"
|
||||
|
||||
for shell in ${VERSIONS_SHELLS}; do
|
||||
shell_version=`versions_shellVersion ${shell}`
|
||||
echo "shell: ${shell} version: ${shell_version}"
|
||||
done
|
||||
}
|
||||
|
||||
if [ "${ARGV0}" = 'versions' ]; then
|
||||
versions_main "$@"
|
||||
fi
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user