summaryrefslogtreecommitdiff
path: root/check
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-08-14 08:57:25 +0300
committerLars Wirzenius <liw@liw.fi>2021-08-14 13:13:48 +0300
commitaca2bc890c8345718724b5b73dde5968fe25c65b (patch)
tree21f7735d7431f83b1ec8c6f8066765b47e2935f5 /check
parentdf3d2db5ddfe2b0aa988a41dc6e840ebd4af6435 (diff)
downloadsubplot-aca2bc890c8345718724b5b73dde5968fe25c65b.tar.gz
test: query Cargo for its target directory
Run "cargo metadata" to get the location of the Cargo "target" directory. The location of the directory is configurable by the user, so we can't assume it's "target" in the source tree. It turned out that running "cargo metadata" in a scenario didn't work well, because cargo wants to use some files from the user's home directory, and for scenarios, that's changed (by setting $HOME). To work around this, the generated test program now requires SUBPLOT_DIR to be set when running the generated Python test programs. The "./check" script does that. Sponsored-by: author
Diffstat (limited to 'check')
-rwxr-xr-xcheck24
1 files changed, 23 insertions, 1 deletions
diff --git a/check b/check
index 1220ad8..601f900 100755
--- a/check
+++ b/check
@@ -2,6 +2,7 @@
import argparse
import glob
+import json
import os
import sys
import time
@@ -236,8 +237,19 @@ def check_subplots(r):
if os.path.exists(test_log):
os.remove(test_log)
+ bindir = get_bin_dir(r)
+
r.codegen(md, test_py, cwd=dirname)
- p = r.runcmd_unchecked(["python3", test_py, "--log", test_log], cwd=dirname)
+ p = r.runcmd_unchecked(
+ [
+ "python3",
+ test_py,
+ "--log",
+ test_log,
+ f"--env=SUBPLOT_DIR={bindir}",
+ ],
+ cwd=dirname,
+ )
if p.returncode != 0:
if os.path.exists(test_log):
tail(test_log)
@@ -354,6 +366,16 @@ def parse_args():
return p.parse_args()
+def get_bin_dir(r):
+ p = r.runcmd(
+ ["cargo", "metadata", "--format-version=1", "--frozen", "--no-deps"],
+ check=True,
+ stdout=PIPE,
+ )
+ obj = json.loads(p.stdout)
+ return os.path.join(obj["target_directory"], "debug")
+
+
def main():
"""Main program"""
args = parse_args()