-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rpc): extend search path, remove cd
- Loading branch information
Andrew Kent
committed
Apr 1, 2021
1 parent
f1e753b
commit 5dd9be0
Showing
10 changed files
with
134 additions
and
65 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
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
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
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
7 changes: 7 additions & 0 deletions
7
cryptol-remote-api/python/tests/cryptol/test-files/test-subdir/Bar.cry
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,7 @@ | ||
module Bar where | ||
|
||
id : {n} (fin n) => [n] -> [n] | ||
id a = a | ||
|
||
theAnswer : [8] | ||
theAnswer = 42 |
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,45 @@ | ||
import unittest | ||
from pathlib import Path | ||
import os | ||
from pathlib import Path | ||
import subprocess | ||
import time | ||
import unittest | ||
import signal | ||
from distutils.spawn import find_executable | ||
import cryptol | ||
import argo_client.connection as argo | ||
import cryptol.cryptoltypes | ||
from cryptol import solver | ||
from cryptol.bitvector import BV | ||
from BitVector import * #type: ignore | ||
|
||
|
||
# Tests of the core server functionality and less | ||
# focused on intricate Cryptol specifics per se. | ||
|
||
class BasicServerTests(unittest.TestCase): | ||
# Connection to cryptol | ||
c = None | ||
|
||
@classmethod | ||
def setUpClass(self): | ||
self.c = cryptol.connect() | ||
|
||
@classmethod | ||
def tearDownClass(self): | ||
if self.c: | ||
self.c.reset() | ||
|
||
def test_extend_search_path(self): | ||
"""Test that extending the search path acts as expected w.r.t. loads.""" | ||
c = self.c | ||
|
||
c.extend_search_path(str(Path('tests','cryptol','test-files', 'test-subdir'))) | ||
c.load_module('Bar') | ||
ans1 = c.evaluate_expression("theAnswer").result() | ||
ans2 = c.evaluate_expression("id theAnswer").result() | ||
self.assertEqual(ans1, ans2) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
7 changes: 7 additions & 0 deletions
7
cryptol-remote-api/python/tests/cryptol_eval/test-files/test-subdir/Bar.cry
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,7 @@ | ||
module Bar where | ||
|
||
id : {n} (fin n) => [n] -> [n] | ||
id a = a | ||
|
||
theAnswer : [8] | ||
theAnswer = 42 |
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
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
module CryptolServer.ExtendSearchPath | ||
( extSearchPath | ||
, extSearchPathDescr | ||
, ExtendSearchPathParams(..) | ||
) where | ||
|
||
|
||
import qualified Argo | ||
import qualified Argo.Doc as Doc | ||
import Data.Aeson as JSON ( (.:), withObject, FromJSON(parseJSON) ) | ||
|
||
import CryptolServer | ||
|
||
-- | Documentation for @extendSearchPath@ | ||
extSearchPathDescr :: Doc.Block | ||
extSearchPathDescr = | ||
Doc.Paragraph | ||
[Doc.Text "Extend the server's search path with the given paths."] | ||
|
||
-- | Extend the search path with the provided directories. | ||
extSearchPath :: ExtendSearchPathParams -> CryptolCommand () | ||
extSearchPath (ExtendSearchPathParams newDirs) = | ||
CryptolCommand $ const $ Argo.modifyState (extendSearchPath newDirs) | ||
|
||
data ExtendSearchPathParams | ||
= ExtendSearchPathParams [FilePath] | ||
|
||
instance FromJSON ExtendSearchPathParams where | ||
parseJSON = | ||
withObject "params for \"extend search path\"" $ | ||
\o -> ExtendSearchPathParams <$> o .: "paths" | ||
|
||
instance Doc.DescribedParams ExtendSearchPathParams where | ||
parameterFieldDescription = | ||
[("paths", | ||
Doc.Paragraph [Doc.Text "The paths to add to the search path."]) | ||
] |