Skip to content

Commit

Permalink
tests run
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas McDonald committed Aug 18, 2023
1 parent 7c9fe47 commit 022511b
Show file tree
Hide file tree
Showing 21 changed files with 77 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

from simple_extendable_resources_internaldafny_types import (
IExtendableResource as DafnyIExtendableResource
)
import ExtendableResource
from simple_extendable_resources.smithygenerated.models import IExtendableResource
import simple_extendable_resources_internaldafny_nativeresourcefactory

class NativeResource(IExtendableResource):
_impl: DafnyIExtendableResource

def __init__(self, _impl):
self._impl = _impl

def GetExtendableResourceData(self, nativeInput):
print("nativeInput")
print(nativeInput)
a = self._impl.GetExtendableResourceData(nativeInput)
print("a")
print(a)
return a

def AlwaysModeledError(self, nativeInput):
print("AlwaysModeledError")
print(nativeInput)
return self._impl.AlwaysModeledError(nativeInput)

def AlwaysMultipleErrors(self, nativeInput):
return self._impl.AlwaysMultipleErrors(nativeInput)

def AlwaysOpaqueError(self, nativeInput):
if nativeInput.value == None:
raise Exception("Python Hard Coded Exception")
return self._impl.AlwaysOpaqueError(nativeInput)

class NativeResourceFactory:

@staticmethod
def DafnyFactory():
dafny_resource = ExtendableResource.ExtendableResource()
dafny_resource.ctor__()
native_resource = NativeResource(dafny_resource)

# to_dafny
return native_resource


simple_extendable_resources_internaldafny_nativeresourcefactory.default__ = NativeResourceFactory

DafnyFactory = NativeResourceFactory
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import simple_extendable_resources_internaldafny_wrapped
from simple_extendable_resources.smithygenerated.client import SimpleExtendableResources
from simple_extendable_resources.smithygenerated.shim import SimpleExtendableResourcesShim
from simple_extendable_resources.smithygenerated.config import dafny_config_to_smithy_config
import Wrappers

@staticmethod
def WrappedSimpleExtendableResources(config):
wrapped_config = config
wrapped_config = dafny_config_to_smithy_config(config)
impl = SimpleExtendableResources(wrapped_config)
wrapped_client = SimpleExtendableResourcesShim(impl)
return Wrappers.Result_Success(wrapped_client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
# This is not generated; these must be manually added.

from simple_extendable_resources.extern import wrapped_simple_extendable_resources
from simple_extendable_resources.extern import native_resource

# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import simple_resources_internaldafny_wrapped
from simple_resources.smithygenerated.client import SimpleResources
from simple_resources.smithygenerated.shim import SimpleResourcesShim
from simple_resources.smithygenerated.config import dafny_config_to_smithy_config
import Wrappers

@staticmethod
def WrappedSimpleResources(config):
wrapped_config = config
wrapped_config = dafny_config_to_smithy_config(config)
impl = SimpleResources(wrapped_config)
wrapped_client = SimpleResourcesShim(impl)
return Wrappers.Result_Success(wrapped_client)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
2 changes: 1 addition & 1 deletion TestModels/Resource/runtimes/python/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ commands_pre =
poetry lock
poetry install
commands =
poetry run pytest test/ --import-mode importlib
poetry run pytest test/ -s -v --import-mode importlib
5 changes: 3 additions & 2 deletions TestModels/SharedMakefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,13 @@ _comment_out_import_module_python:
# For a Dafny-generated module X, comment out `import module_`
# This import results in circular dependencies
find runtimes/python/src/$(PYTHON_MODULE_NAME)/dafnygenerated -type f -exec sed -i $(SED_PARAMETER) '/import module\_/s/^/# /g' {} \;
find runtimes/python/test/dafnygenerated -type f -exec sed -i $(SED_PARAMETER) '/import module\_/s/^/# /g' {} \;
rm runtimes/python/src/$(PYTHON_MODULE_NAME)/dafnygenerated/module_.py
# find runtimes/python/test/dafnygenerated -type f -exec sed -i $(SED_PARAMETER) '/import module\_/s/^/# /g' {} \;

transpile_dependencies_python: LANG=python
transpile_dependencies_python: transpile_dependencies

test_python:
tox -c runtimes/python
tox -c runtimes/python --verbose

clean: _clean
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# End import modules required for Dafny-generated tests

def test_dafny():
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafny/**/", "*.py"), recursive=True)
dafny_modules = glob.glob(join("/".join(__file__.split("/")[:-2]) + "/dafnygenerated/", "*.py"), recursive=True)
for f in dafny_modules:
if isfile(f) and f.endswith('test.py'):
fname = str(f).split("/")[-1].split(".")[0]
Expand Down
2 changes: 1 addition & 1 deletion submodules/smithy-python
Submodule smithy-python updated 0 files

0 comments on commit 022511b

Please sign in to comment.