on master help sign in
Merge pull request #75 from replit/cb-nixify-prybar-assets

Fix NodeJS prybar in Nix land

commit4a42408b0513ce1eac775f1e81d132c9c39bc380 authorConnor Brewster <cbrewster@hey.com> dateTue 12 Oct 2021, 13:07 (5 years ago) parent922f62852e3681
74 files changed+89−81
build-prybar.nix+13−2 languages/nodejs/repl.js+4−7 run_no_pty+1−1 tests/clojure/all.exp+1−1 tests/clojure/evaluate_expression.exp+1−1 tests/clojure/initialize_code_with_script.exp+1−1 tests/clojure/initialize_expression_with_script.exp+1−1 tests/clojure/initialize_repl_with_script.exp+1−1 tests/clojure/plus_1_1.exp+1−1 tests/clojure/print.exp+1−1 tests/clojure/quiet_repl.exp+1−1 tests/clojure/run_code.exp+1−1 tests/clojure/run_script.exp+1−1 tests/julia/1_plus_1.exp+1−1 tests/julia/header.exp+1−1 tests/julia/input.exp+1−1 tests/julia/print_a_line.exp+1−1 tests/julia/start_with_file.exp+1−1 tests/lua/always_try_expression.exp+1−1 tests/lua/history.exp+1−1 tests/lua/load_file.exp+1−1 tests/lua/ps1_ps2.exp+1−1 tests/lua/quiet.exp+1−1 tests/lua/returns.exp+1−1 tests/nodejs/1_plus_1.exp+1−1 tests/nodejs/confirm.exp+1−1 tests/nodejs/err.exp+1−1 tests/nodejs/eval_code.exp+1−1 tests/nodejs/global_bug.exp+1−1 tests/nodejs/header.exp+1−1 tests/nodejs/module_patching.exp+1−1 tests/nodejs/printing.exp+1−1 tests/nodejs/prompt_escape.exp+1−1 tests/nodejs/prompt_no_tty.exp+1−1 tests/nodejs/prompt_tty.exp+1−1 tests/nodejs/prompt_tty_bounds.exp+1−1 tests/nodejs/prompt_tty_escapes.exp+1−1 tests/nodejs/run_code.exp+1−1 tests/nodejs/run_file.exp+1−1 tests/nodejs/set_ps1.exp+1−1 tests/ocaml/code_print.exp+1−1 tests/ocaml/exception.exp+1−1 tests/ocaml/expr.exp+1−1 tests/ocaml/not_quiet.exp+1−1 tests/ocaml/ps1.exp+1−1 tests/ocaml/ps2.exp+1−1 tests/ocaml/quiet.exp+1−1 tests/python2/1_plus_1.exp+1−1 tests/python2/code_print.exp+1−1 tests/python2/exception.exp+1−1 tests/python2/expr.exp+1−1 tests/python2/ps1.exp+1−1 tests/python2/ps2.exp+1−1 tests/python2/quiet.exp+1−1 tests/python2/stdout_stderr.exp+1−1 tests/python3/1_plus_1.exp+1−1 tests/python3/eval_code.exp+1−1 tests/python3/printing.exp+1−1 tests/python3/run_code.exp+1−1 tests/python3/set_ps1.exp+1−1 tests/python3/set_ps2.exp+1−1 tests/python3/show_header.exp+1−1 tests/python3/stderr_red.exp+1−1 tests/sqlite/1_plus_1.exp+1−1 tests/sqlite/eval.exp+1−1 tests/sqlite/exec.exp+1−1 tests/sqlite/header.exp+1−1 tests/sqlite/quiet.exp+1−1 tests/sqlite/read_file.exp+1−1 tests/tcl/a_few_outputs.exp+1−1 tests/tcl/from_file.exp+1−1 tests/tcl/input_output.exp+1−1 tests/tcl/invalid_command.exp+1−1 tests/tcl/unknown_command.exp+1−1
build-prybar.nix+13−2
@@ -2,7 +2,7 @@
22, pkgName ? language }:
33
44{ lib, buildGoModule, fetchFromGitHub, bash, expect, pkg-config, runCommand, git
5−, python3, copyPathToStore, rev }:
5+, python3, copyPathToStore, rev, makeWrapper }:
66
77buildGoModule {
88 pname = "prybar-${language}";
@@ -11,7 +11,7 @@ buildGoModule {
1111 src = ./.;
1212
1313 inherit buildInputs;
14− nativeBuildInputs = [ pkg-config ];
14+ nativeBuildInputs = [ pkg-config makeWrapper ];
1515
1616 subPackages = [ "languages/${language}" ];
1717
@@ -49,6 +49,8 @@ buildGoModule {
4949 # is running in.
5050 export HOME=$(echo pwd)
5151
52+ patchShebangs run_no_pty ./tests/${language}/*.exp
53+
5254 "${bash}/bin/bash" "./run_tests_language" "${language}" "${expect}/bin"
5355
5456 runHook postCheck
@@ -61,5 +63,14 @@ buildGoModule {
6163
6264 postInstall = ''
6365 mv $out/bin/${language} $out/bin/prybar-${language}
66+
67+ if [ -d "./prybar_assets/${language}" ]
68+ then
69+ mkdir -p "$out/prybar_assets/${language}"
70+ cp -R "./prybar_assets/${language}" "$out/prybar_assets/"
71+
72+ wrapProgram "$out/bin/prybar-${language}" \
73+ --set PRYBAR_ASSETS_DIR "$out/prybar_assets"
74+ fi
6475 '';
6576}
languages/nodejs/repl.js+4−7
@@ -3,13 +3,10 @@ const repl = require("repl");
33const path = require("path");
44const fs = require("fs");
55const vm = require("vm");
6−const { isatty } = require('tty');
7−const rl = require(path.join(
8− process.cwd(),
9− "prybar_assets",
10− "nodejs",
11− "input-sync.js"
12−));
6+const { isatty } = require("tty");
7+const assets_dir =
8+ process.env.PRYBAR_ASSETS_DIR || path.join(process.cwd(), "prybar_assets");
9+const rl = require(path.join(assets_dir, "nodejs", "input-sync.js"));
1310const Module = require("module");
1411
1512let r;
run_no_pty+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env bash
1+#!/bin/bash
22stdin="/tmp/prybar_stdin"
33stdout="/tmp/prybar_stdout"
44stderr="/tmp/prybar_stderr"
tests/clojure/all.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33# ignore ANSI escape sequences
44set _ "(?:.*?)"
tests/clojure/evaluate_expression.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33# ignore ANSI escape sequences
44set _ "(?:.*?)"
tests/clojure/initialize_code_with_script.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33# ignore ANSI escape sequences
44set _ "(?:.*?)"
tests/clojure/initialize_expression_with_script.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33# ignore ANSI escape sequences
44set _ "(?:.*?)"
tests/clojure/initialize_repl_with_script.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33# ignore ANSI escape sequences
44set _ "(?:.*?)"
tests/clojure/plus_1_1.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33# ignore ANSI escape sequences
44set _ "(?:.*?)"
tests/clojure/print.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33# ignore ANSI escape sequences
44set _ "(?:.*?)"
tests/clojure/quiet_repl.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33# ignore ANSI escape sequences
44set _ "(?:.*?)"
tests/clojure/run_code.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-clojure -q -c {(do (println "foo") "bar")}
tests/clojure/run_script.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-clojure ./test_files/hello.clj
44expect eof
tests/julia/1_plus_1.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-julia -q -i
tests/julia/header.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22#
33# This Expect script was generated by autoexpect on Fri Jun 12 21:00:42 2020
44# Expect and autoexpect were both written by Don Libes, NIST.
tests/julia/input.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-julia -q -i
tests/julia/print_a_line.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-julia -q -i
tests/julia/start_with_file.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-julia -q -i ./test_files/hi_julia.jl
tests/lua/always_try_expression.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-lua -q -i
tests/lua/history.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-lua -q -i
tests/lua/load_file.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-lua -i ./test_files/hello.lua
tests/lua/ps1_ps2.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-lua -i -ps1 ps1 -ps2 ps2
tests/lua/quiet.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-lua -q -i
tests/lua/returns.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-lua -q -i
tests/nodejs/1_plus_1.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i -q
tests/nodejs/confirm.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i -q
tests/nodejs/err.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i -q
tests/nodejs/eval_code.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -q -e 1+1
tests/nodejs/global_bug.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i ./test_files/global_bug.js
tests/nodejs/header.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i
tests/nodejs/module_patching.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i ./test_files/global_bug.js
tests/nodejs/printing.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i -q
tests/nodejs/prompt_escape.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i -q
tests/nodejs/prompt_no_tty.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22set timeout -1
33set stty_init raw
44spawn ./run_no_pty ./prybar-nodejs -q -i
tests/nodejs/prompt_tty.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i -q
tests/nodejs/prompt_tty_bounds.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i -q
tests/nodejs/prompt_tty_escapes.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i -q
tests/nodejs/run_code.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -q -c 1+1
tests/nodejs/run_file.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i ./test_files/hello.js
tests/nodejs/set_ps1.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-nodejs -i -q -ps1 custom
tests/ocaml/code_print.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-ocaml -q -c "print_endline(\"hello world\")"
44match_max 100000
tests/ocaml/exception.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-ocaml -q -i
44match_max 100000
tests/ocaml/expr.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-ocaml -q -e 1+1
44match_max 100000
tests/ocaml/not_quiet.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-ocaml -e 1+1
44match_max 100000
tests/ocaml/ps1.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-ocaml -q -i -ps1 ">>"
44match_max 100000
tests/ocaml/ps2.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-ocaml -q -i -ps2 continuation
44match_max 100000
tests/ocaml/quiet.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-ocaml -q -i
44match_max 100000
tests/python2/1_plus_1.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-python2 -i
44match_max 100000
tests/python2/code_print.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-python2 -q -c print('hello')
44match_max 100000
tests/python2/exception.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-python2 -q -i
44match_max 100000
tests/python2/expr.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-python2 -e 1+1
44match_max 100000
tests/python2/ps1.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-python2 -i -ps1 somethingelse
44match_max 100000
tests/python2/ps2.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-python2 -i -ps2 continuation
44match_max 100000
tests/python2/quiet.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-python2 -q -i
44match_max 100000
tests/python2/stdout_stderr.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-python2 -q -i
44match_max 100000
tests/python3/1_plus_1.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-python3 -i -q
tests/python3/eval_code.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-python3 -e 1+1
tests/python3/printing.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-python3 -i -q
tests/python3/run_code.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-python3 -c print('hello')
tests/python3/set_ps1.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-python3 -i -q -ps1 custom
tests/python3/set_ps2.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-python3 -i -q -ps2 custom
tests/python3/show_header.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-python3 -i
tests/python3/stderr_red.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33# red is currently nondeterministic
44exit 0
tests/sqlite/1_plus_1.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-sqlite -q -i
44expect -- "^--> "
tests/sqlite/eval.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-sqlite -e "select 1+1;"
44expect ^2
tests/sqlite/exec.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-sqlite -c "select 1+1;"
44expect ^eof
tests/sqlite/header.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-sqlite -i
44expect -gl "-- Loading resources from /tmp/sqlite-config*\r\nSQLite version 3.27.2*\r\nEnter \".help\" for usage hints.\r\n--> "
tests/sqlite/quiet.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-sqlite -q -i
44expect "^--> "
tests/sqlite/read_file.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33spawn ./prybar-sqlite -q -i ./test_files/hello.sql
44expect -- "^hey there\r
tests/tcl/a_few_outputs.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-tcl -q -i
tests/tcl/from_file.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-tcl -q -i ./test_files/hello_tcl.tcl
tests/tcl/input_output.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-tcl -q -i
tests/tcl/invalid_command.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-tcl -q -i ./test-files/hi_julia.jl
tests/tcl/unknown_command.exp+1−1
@@ -1,4 +1,4 @@
1−#!/usr/bin/env -S expect -f
1+#!/usr/bin/expect -f
22
33set timeout -1
44spawn ./prybar-tcl -q -i