-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
杨赫然
committed
Oct 25, 2024
1 parent
781bb53
commit dc98b4c
Showing
4 changed files
with
83 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -e -x | ||
|
||
SCRIPT=${BASH_SOURCE[0]} | ||
TESTS_DIR=$(dirname "${SCRIPT}")/.. | ||
SETUP_DIR=${TESTS_DIR}/ci | ||
|
||
cd $SETUP_DIR | ||
|
||
pip install -r requirements.txt |
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,4 @@ | ||
termcolor>=2.3.0 | ||
requests>=2.31.0 | ||
pytest>=7.4.0 | ||
pytest-instafail |
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,18 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
|
||
from utils import setup_logging, shell | ||
from os.path import abspath, join | ||
|
||
TOPDIR = abspath(join(os.getcwd())) | ||
|
||
|
||
def main(): | ||
shell("py.test", env=dict(os.environ)) | ||
|
||
|
||
|
||
if __name__ == "__main__": | ||
setup_logging() | ||
main() |
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,50 @@ | ||
import os | ||
import logging | ||
from subprocess import PIPE, CalledProcessError, Popen | ||
import sys | ||
|
||
import termcolor | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def setup_logging(): | ||
kw = { | ||
"format": "[%(asctime)s][%(module)s]: %(message)s", | ||
"datefmt": "%m/%d/%Y %H:%M:%S", | ||
"level": logging.DEBUG, | ||
"stream": sys.stdout, | ||
} | ||
|
||
logging.basicConfig(**kw) | ||
logging.getLogger("requests.packages.urllib3.connectionpool").setLevel( | ||
logging.WARNING | ||
) | ||
|
||
|
||
def shell(cmd, inputdata=None, wait=True, **kw): | ||
info('calling "%s" in %s', cmd, kw.get("cwd", os.getcwd())) | ||
kw["shell"] = not isinstance(cmd, list) | ||
kw["stdin"] = PIPE if inputdata else None | ||
p = Popen(cmd, **kw) | ||
if inputdata: | ||
p.communicate(inputdata) | ||
if wait: | ||
p.wait() | ||
if p.returncode: | ||
raise CalledProcessError(p.returncode, cmd) | ||
else: | ||
return p | ||
|
||
|
||
def info(fmt, *a): | ||
logger.info(green(fmt), *a) | ||
|
||
|
||
def green(s): | ||
return _color(s, "green") | ||
|
||
|
||
def _color(s, color): | ||
return s if not os.isatty(sys.stdout.fileno()) else termcolor.colored(str(s), color) |