Run file using hy -i
Add test for -i using file
This commit is contained in:
parent
a3775316e7
commit
a3ad4df6a1
@ -31,6 +31,7 @@ import argparse
|
||||
import code
|
||||
import ast
|
||||
import sys
|
||||
import os
|
||||
|
||||
import astor.codegen
|
||||
|
||||
@ -244,7 +245,13 @@ def run_repl(hr=None, spy=False):
|
||||
|
||||
def run_icommand(source, spy=False):
|
||||
hr = HyREPL(spy)
|
||||
hr.runsource(source, filename='<input>', symbol='single')
|
||||
if os.path.exists(source):
|
||||
with open(source, "r") as f:
|
||||
source = f.read()
|
||||
filename = source
|
||||
else:
|
||||
filename = '<input>'
|
||||
hr.runsource(source, filename=filename, symbol='single')
|
||||
return run_repl(hr)
|
||||
|
||||
|
||||
|
@ -79,6 +79,14 @@ def test_bin_hy_icmd():
|
||||
assert "figlet" in output
|
||||
|
||||
|
||||
def test_bin_hy_icmd_file():
|
||||
ret = run_cmd("hy -i test_files/icmd_test_file.hy", "(ideas)")
|
||||
assert ret[0] == 0
|
||||
output = ret[1]
|
||||
|
||||
assert "Hy!" in output
|
||||
|
||||
|
||||
def test_bin_hy_icmd_and_spy():
|
||||
ret = run_cmd("hy -i \"(+ [] [])\" --spy", "(+ 1 1)")
|
||||
assert ret[0] == 0
|
||||
|
1
tests/test_files/icmd_test_file.hy
Normal file
1
tests/test_files/icmd_test_file.hy
Normal file
@ -0,0 +1 @@
|
||||
(print "Hy!")
|
Loading…
Reference in New Issue
Block a user