summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-15 05:26:51 +0000
committerLars Wirzenius <liw@liw.fi>2021-09-15 05:26:51 +0000
commit1205d5067e615f9d32a3403a80504ae4d54c22bf (patch)
tree84245aed6bb97d975cd0ca08a6ac4a9480f32ea5
parenta48c5dfc48a9aea22e7dbc34a74a45f1e4dcade9 (diff)
parenteccb45b085a5b0e930b29efbd74deaeb4e2b5b73 (diff)
downloadewww-1205d5067e615f9d32a3403a80504ae4d54c22bf.tar.gz
Merge branch 'fix-subplot' into 'main'
fix: use impl in bindings file, for new Subplot See merge request larswirzenius/ewww!25
-rwxr-xr-xcheck63
-rw-r--r--subplot/ewww.py14
-rw-r--r--subplot/ewww.yaml42
3 files changed, 65 insertions, 54 deletions
diff --git a/check b/check
index 272ee63..ceffb0e 100755
--- a/check
+++ b/check
@@ -4,63 +4,58 @@ set -eu
verbose=false
moar=true
-while [ "$#" -gt 0 ] && $moar
-do
- case "$1" in
+while [ "$#" -gt 0 ] && $moar; do
+ case "$1" in
verbose | -v | --verbose)
- verbose=true
- shift 1
- ;;
- esac
+ verbose=true
+ shift 1
+ ;;
+ esac
done
hideok=
-if command -v chronic > /dev/null
-then
- hideok=chronic
+if command -v chronic >/dev/null; then
+ hideok=chronic
fi
quiet=-q
-if $verbose
-then
- quiet=
- hideok=
+if $verbose; then
+ quiet=
+ hideok=
fi
-
codegen() {
- $hideok subplot codegen "$1" --output "$2"
- rm -f test.log
- $hideok python3 test.py --log test.log
+ target="$(cargo metadata --format-version=1 |
+ python3 -c 'import sys, json; o = json.load(sys.stdin); print(o["target_directory"])')"
+ $hideok subplot codegen "$1" --output "$2"
+ rm -f test.log
+ $hideok python3 test.py --log test.log --env "CARGO_TARGET_DIR=$target"
}
docgen() {
- subplot docgen "$1" --output "$2"
+ subplot docgen "$1" --output "$2"
}
$hideok cargo build --all-targets
-if cargo --list | awk '{ print $1 }' | grep 'clippy$' > /dev/null
-then
- # shellcheck disable=SC2086
- cargo clippy $quiet
+if cargo --list | awk '{ print $1 }' | grep 'clippy$' >/dev/null; then
+ # shellcheck disable=SC2086
+ cargo clippy $quiet
fi
# shellcheck disable=SC2086
$hideok cargo test $quiet
-if cargo fmt --help > /dev/null 2> /dev/null
-then
- $hideok cargo fmt -- --check
+if cargo fmt --help >/dev/null 2>/dev/null; then
+ $hideok cargo fmt -- --check
fi
-$hideok ./mktestcert test.key test.pem hunter2
+$hideok ./mktestcert test.key test.pem hunter2
-for md in [^R]*.md
-do
- $hideok echo "$md ====================================="
- codegen "$md" test.py
- docgen "$md" "$(basename "$md" .md).pdf"
- docgen "$md" "$(basename "$md" .md).html"
- $hideok echo
+for md in [^R]*.md; do
+ $hideok echo "$md ====================================="
+ codegen "$md" test.py
+ docgen "$md" "$(basename "$md" .md).pdf"
+ docgen "$md" "$(basename "$md" .md).html"
+ $hideok echo
done
echo "Everything seems to be in order."
diff --git a/subplot/ewww.py b/subplot/ewww.py
index a6c4c4f..11915ae 100644
--- a/subplot/ewww.py
+++ b/subplot/ewww.py
@@ -10,12 +10,6 @@ import urllib.parse
import yaml
-# Name of Rust binary, debug-build.
-def _binary(name):
- srcdir = globals()["srcdir"]
- return os.path.abspath(os.path.join(srcdir, "target", "debug", name))
-
-
# Write a file with given content.
def _write(filename, content):
open(filename, "w").write(content)
@@ -59,6 +53,7 @@ def copy_test_certificate(ctx, cert=None, key=None):
# Start server using named configuration file.
def start_server(ctx, filename=None):
get_file = globals()["get_file"]
+ srcdir = globals()["srcdir"]
daemon_start_on_port = globals()["daemon_start_on_port"]
logging.debug(f"Starting ewww with config file {filename}")
@@ -72,9 +67,10 @@ def start_server(ctx, filename=None):
config = yaml.safe_dump(config)
_write(filename, config)
- daemon_start_on_port(
- ctx, path=_binary("ewww"), args=filename, name="ewww", port=port
- )
+ target = os.environ.get("CARGO_TARGET_DIR", os.path.join(srcdir, "target"))
+ logging.debug(f"Cargo target directory: {target}")
+ binary = os.path.join(target, "debug", "ewww")
+ daemon_start_on_port(ctx, binary, args=filename, name="ewww", port=port)
# Stop previously started server.
diff --git a/subplot/ewww.yaml b/subplot/ewww.yaml
index 7353863..d59a5fd 100644
--- a/subplot/ewww.yaml
+++ b/subplot/ewww.yaml
@@ -1,33 +1,53 @@
- given: a self-signed certificate as {cert}, using key {key}
- function: copy_test_certificate
+ impl:
+ python:
+ function: copy_test_certificate
- given: a running server using config file {filename}
- function: start_server
- cleanup: stop_server
+ impl:
+ python:
+ function: start_server
+ cleanup: stop_server
- given: directory {dirname}
- function: create_directory
+ impl:
+ python:
+ function: create_directory
- then: I am redirected to {location}
- function: fixme
+ impl:
+ python:
+ function: fixme
- then: I can do at least {number} requests per second
- function: fixme
+ impl:
+ python:
+ function: fixme
- then: I get status code {code}
- function: http_status_code_is
+ impl:
+ python:
+ function: http_status_code_is
- then: 'header (?P<header>\S+) is "(?P<value>.+)"'
regex: true
- function: http_header_is
+ impl:
+ python:
+ function: http_header_is
- then: 'body is "(?P<body>.*)"'
regex: true
- function: http_body_is
+ impl:
+ python:
+ function: http_body_is
- when: I request {method} {url}
- function: request
+ impl:
+ python:
+ function: request
- when: I request files under {url} in random order {count} times
- function: fixme
+ impl:
+ python:
+ function: fixme