Skip to content

Commit 8698121

Browse files
committed
fix: does this work on windows?
1 parent ce254bc commit 8698121

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

aws_lambda_builders/workflows/provided_make/actions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Action to build a specific Makefile target
33
"""
44

5-
import os
65
import logging
76

87
from aws_lambda_builders.actions import BaseAction, Purpose, ActionFailedError
@@ -58,8 +57,10 @@ def execute(self):
5857
self.osutils.makedirs(self.artifacts_dir)
5958

6059
try:
61-
current_env = os.environ.copy()
62-
current_env.update({"ARTIFACTS_DIR": self.artifacts_dir})
60+
current_env = self.osutils.environ().copy()
61+
norm_abs_artifacts_dir = self.osutils.abspath(self.osutils.normpath(self.artifacts_dir))
62+
LOG.info("Current Artifacts Directory : %s", norm_abs_artifacts_dir)
63+
current_env.update({"ARTIFACTS_DIR": norm_abs_artifacts_dir})
6364
self.subprocess_make.run(
6465
["build-{logical_id}".format(logical_id=self.build_logical_id)], env=current_env, cwd=self.scratch_dir,
6566
)

aws_lambda_builders/workflows/provided_make/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ def popen(self, command, stdout=None, stderr=None, env=None, cwd=None):
2424
p = subprocess.Popen(command, stdout=stdout, stderr=stderr, env=env, cwd=cwd)
2525
return p
2626

27+
def environ(self):
28+
return os.environ
29+
30+
def normpath(self, path):
31+
return os.path.normpath(path)
32+
33+
def abspath(self, path):
34+
return os.path.abspath(path)
35+
2736
@property
2837
def pipe(self):
2938
return subprocess.PIPE

tests/unit/workflows/provided_make/test_actions.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import os
22

33
from unittest import TestCase
4-
from mock import patch
4+
5+
from mock import patch, ANY
56

67
from aws_lambda_builders.actions import ActionFailedError
78
from aws_lambda_builders.workflows.provided_make.actions import ProvidedMakeAction
@@ -37,9 +38,7 @@ def test_call_makefile_target(self, OSUtilMock, SubprocessMakeMock):
3738

3839
action.execute()
3940

40-
subprocess_make.run.assert_called_with(
41-
["build-logical_id"], env={"ARTIFACTS_DIR": "artifacts"}, cwd="scratch_dir"
42-
)
41+
subprocess_make.run.assert_called_with(["build-logical_id"], env=ANY, cwd="scratch_dir")
4342

4443
@patch("aws_lambda_builders.workflows.provided_make.utils.OSUtils")
4544
@patch("aws_lambda_builders.workflows.provided_make.make.SubProcessMake")
@@ -65,6 +64,4 @@ def test_makefile_target_fails(self, OSUtilMock, SubprocessMakeMock):
6564
with self.assertRaises(ActionFailedError):
6665
action.execute()
6766

68-
subprocess_make.run.assert_called_with(
69-
["build-logical_id"], env={"ARTIFACTS_DIR": "artifacts"}, cwd="scratch_dir"
70-
)
67+
subprocess_make.run.assert_called_with(["build-logical_id"], env=ANY, cwd="scratch_dir")

0 commit comments

Comments
 (0)