-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from roguh/2021.10.31_fix_cicd_and_lint
Add unit tests, other changes
- Loading branch information
Showing
14 changed files
with
351 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
test-results* | ||
.test-pass-count | ||
coverage/ | ||
tests/shellspec/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
import sys | ||
|
||
# define subcommands to mock git behavior: | ||
# DONE if git rev-parse, if in git-repo exit 0 else exit 1 | ||
# DONE if git remote update, do nothing | ||
# DONE if rev-parse @, show local_branch | ||
# DONE if rev-parse @{u}, show remote_branch | ||
# DONE if merge-parse @{u}, show base_branch | ||
# DONE if branch --show-current, print local_branch_name | ||
# DONE if push or pull, print all args | ||
|
||
# unit test: define git() as ./this.py <CONFIG ARGS> "$@" | ||
|
||
|
||
def rev_parse(args): | ||
if args.git_dir: | ||
sys.exit(1 if args.not_in_a_git_repo else 0) | ||
elif args.rev == "@": | ||
print(args.local_branch) | ||
elif args.rev == "@{u}": | ||
print(args.remote_branch) | ||
else: | ||
raise NotImplementedError(f"rev={args.rev}") | ||
|
||
|
||
def remote(_): | ||
# Do nothing but successfully exit | ||
pass | ||
|
||
|
||
def merge_base(args): | ||
if args.rev == "@" and args.upstream_rev == "@{u}": | ||
print(args.base_branch) | ||
else: | ||
raise NotImplementedError(f"rev={args.rev} upstream_rev={args.upstream_rev}") | ||
|
||
|
||
def branch(args): | ||
if args.show_current: | ||
print(args.local_branch_name) | ||
else: | ||
raise NotImplementedError("show_current=False") | ||
|
||
|
||
def push(args): | ||
pass | ||
|
||
|
||
def pull(args): | ||
pass | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description="Mocks git subcommands used by gp") | ||
|
||
parser.add_argument("--not-in-a-git-repo", action="store_true") | ||
parser.add_argument("--local-branch", default=None) | ||
parser.add_argument("--remote-branch", default=None) | ||
parser.add_argument("--base-branch", default=None) | ||
parser.add_argument("--local-branch-name", default=None) | ||
|
||
subparsers = parser.add_subparsers() | ||
|
||
rev_parse_parser = subparsers.add_parser("rev-parse") | ||
rev_parse_parser.add_argument("rev", nargs="?") | ||
rev_parse_parser.add_argument("--git-dir", action="store_true") | ||
rev_parse_parser.set_defaults(func=rev_parse) | ||
|
||
remote_parser = subparsers.add_parser("remote") | ||
remote_parser.add_argument("remote_update_args", nargs="*") | ||
remote_parser.set_defaults(func=remote) | ||
|
||
merge_base_parser = subparsers.add_parser("merge-base") | ||
merge_base_parser.add_argument("rev", type=str) | ||
merge_base_parser.add_argument("upstream_rev", type=str) | ||
merge_base_parser.set_defaults(func=merge_base) | ||
|
||
branch_parser = subparsers.add_parser("branch") | ||
branch_parser.add_argument("--show-current", action="store_true", required=True) | ||
branch_parser.set_defaults(func=branch) | ||
|
||
push_parser = subparsers.add_parser("push") | ||
push_parser.set_defaults(func=push) | ||
|
||
pull_parser = subparsers.add_parser("pull") | ||
pull_parser.set_defaults(func=pull) | ||
|
||
# Ignore unknown arguments | ||
args, _ = parser.parse_known_args() | ||
args.func(args) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
if [ "$#" = 0 ]; then | ||
echo "USAGE: $0 [SHELLS...]" | ||
echo | ||
echo "SHELLS can be a list of any installed shells" | ||
echo "Examples: bash, zsh, dash, yash" | ||
exit 1 | ||
fi | ||
|
||
set -e | ||
for shell in "$@"; do | ||
"$(dirname "$0")/test-unit.sh" "$shell" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
if [ "$#" != 1 ]; then | ||
echo "USAGE: $0 [SHELL]" | ||
echo | ||
echo "SHELL can be any installed shells" | ||
echo "Examples: bash, zsh, dash, yash" | ||
exit 1 | ||
fi | ||
"$(dirname "$0")/shellspec/shellspec" --shell "$1" --helperdir tests/unit_tests/spec --sandbox tests/unit_tests/gp_spec.sh |
Oops, something went wrong.