Skip to content

Commit 4cd119c

Browse files
authored
Revert "fix: helpful error messages when runtime mismatch for build (#37)"
This reverts commit 608813c.
1 parent fe4c87d commit 4cd119c

File tree

4 files changed

+7
-27
lines changed

4 files changed

+7
-27
lines changed

aws_lambda_builders/exceptions.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ class UnsupportedManifestError(LambdaBuilderError):
1616

1717

1818
class MisMatchRuntimeError(LambdaBuilderError):
19-
MESSAGE = "{language} executable found in your path does not " \
20-
"match runtime. " \
21-
"\n Expected version: {required_runtime}, Found version: {found_runtime}. " \
22-
"\n Possibly related: https://github.com/awslabs/aws-lambda-builders/issues/30"
19+
MESSAGE = "A runtime version mismatch was found for the given language " \
20+
"'{language}', required runtime '{required_runtime}'"
2321

2422

2523
class WorkflowNotFoundError(LambdaBuilderError):

aws_lambda_builders/validate.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ def validate_python_cmd(required_language, required_runtime_version):
1717
"python",
1818
"-c",
1919
"import sys; "
20-
"sys.stdout.write('python' + str(sys.version_info.major) + '.' + str(sys.version_info.minor)); "
2120
"assert sys.version_info.major == {major} "
2221
"and sys.version_info.minor == {minor}".format(
2322
major=major,
@@ -64,11 +63,10 @@ def validate_runtime(cls, required_language, required_runtime):
6463
p = subprocess.Popen(cmd,
6564
cwd=os.getcwd(),
6665
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
67-
found_runtime, _ = p.communicate()
66+
p.communicate()
6867
if p.returncode != 0:
6968
raise MisMatchRuntimeError(language=required_language,
70-
required_runtime=required_runtime,
71-
found_runtime=str(found_runtime.decode('utf-8')))
69+
required_runtime=required_runtime)
7270
else:
7371
LOG.warning("'%s' runtime has not "
7472
"been validated!", required_language)

tests/integration/workflows/python_pip/test_python_pip.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from unittest import TestCase
77

88
from aws_lambda_builders.builder import LambdaBuilder
9-
from aws_lambda_builders.exceptions import WorkflowFailedError, MisMatchRuntimeError
9+
from aws_lambda_builders.exceptions import WorkflowFailedError
1010

1111

1212
class TestPythonPipWorkflow(TestCase):
@@ -33,12 +33,6 @@ def setUp(self):
3333
language=self.builder.capability.language,
3434
major=sys.version_info.major,
3535
minor=sys.version_info.minor)
36-
self.runtime_mismatch = {
37-
'python3.6': 'python2.7',
38-
'python3.7': 'python2.7',
39-
'python2.7': 'python3.6'
40-
41-
}
4236

4337
def tearDown(self):
4438
shutil.rmtree(self.artifacts_dir)
@@ -52,15 +46,6 @@ def test_must_build_python_project(self):
5246
output_files = set(os.listdir(self.artifacts_dir))
5347
self.assertEquals(expected_files, output_files)
5448

55-
def test_mismatch_runtime_python_project(self):
56-
with self.assertRaises(MisMatchRuntimeError) as mismatch_error:
57-
self.builder.build(self.source_dir, self.artifacts_dir, self.scratch_dir, self.manifest_path_valid,
58-
runtime=self.runtime_mismatch[self.runtime])
59-
self.assertEquals(mismatch_error.msg,
60-
MisMatchRuntimeError(language="python",
61-
required_runtime=self.runtime_mismatch[self.runtime],
62-
found_runtime=self.runtime).MESSAGE)
63-
6449
def test_runtime_validate_python_project_fail_open_unsupported_runtime(self):
6550
with self.assertRaises(WorkflowFailedError):
6651
self.builder.build(self.source_dir, self.artifacts_dir, self.scratch_dir, self.manifest_path_valid,

tests/unit/test_runtime.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self, returncode):
1313
self.returncode = returncode
1414

1515
def communicate(self):
16-
return b'python3,6', None
16+
pass
1717

1818

1919
class TestRuntime(TestCase):
@@ -44,7 +44,6 @@ def test_runtime_validate_mismatch_version_runtime(self):
4444

4545
def test_python_command(self):
4646
cmd = validate_python_cmd("python", "python2.7")
47-
version_strings = ["sys.stdout.write", "sys.version_info.major == 2",
48-
"sys.version_info.minor == 7"]
47+
version_strings = ["sys.version_info.major == 2", "sys.version_info.minor == 7"]
4948
for version_string in version_strings:
5049
self.assertTrue(any([part for part in cmd if version_string in part]))

0 commit comments

Comments
 (0)