Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Fix writing to a file on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Lesiak committed May 22, 2023
1 parent fcdc6e0 commit dcf2dd1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 6 additions & 2 deletions src/dune/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,14 @@ def rm_file(self, file_name):
self.execute_cmd(['rm', '-rf', file_name])

def write_file(self, file_name, body):
with tempfile.NamedTemporaryFile(mode='w+',) as tmp:
tmp_name = ""
with tempfile.NamedTemporaryFile(mode='w+', delete=False) as tmp:
tmp.write(body)
tmp.flush()
self.cp_from_host(tmp.name, file_name)
tmp_name = tmp.name

self.cp_from_host(tmp_name, file_name)
os.unlink(tmp_name)

def find_pid(self, process_name):
stdout, stderr, exit_code = self.execute_cmd(['ps', 'ax'])
Expand Down
8 changes: 5 additions & 3 deletions tests/common.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@


import os
import platform

# Find path for tests:
TEST_PATH = os.path.dirname(os.path.abspath(__file__))

# Set path for executable:
DUNE_EXE = os.path.split(TEST_PATH)[0] + "/dune"
if platform.system() == 'Windows':
DUNE_EXE = os.path.split(TEST_PATH)[0] + "\dune.bat"
else:
DUNE_EXE = os.path.split(TEST_PATH)[0] + "/dune"
print("Executable path: ", DUNE_EXE)

# Default addresses
Expand Down

0 comments on commit dcf2dd1

Please sign in to comment.