Skip to content

Commit

Permalink
Merge remote-tracking branch 'richtja/tmpfile_fix'
Browse files Browse the repository at this point in the history
Signed-off-by: Cleber Rosa <[email protected]>
  • Loading branch information
clebergnu committed Jan 16, 2024
2 parents 2ff17fc + f4ffe82 commit ab0107f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions optional_plugins/html/tests/html_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def test_output_incompatible_setup(self):

def test_output_compatible_setup_2(self):
prefix = "avocado_" + __name__
tmpfile = tempfile.mktemp(prefix=prefix, dir=self.tmpdir.name)
tmpfile2 = tempfile.mktemp(prefix=prefix, dir=self.tmpdir.name)
tmpfile = os.path.join(self.tmpdir.name, f"{prefix}_result.xml")
tmpfile2 = os.path.join(self.tmpdir.name, f"{prefix}_result.json")
tmpdir = tempfile.mkdtemp(prefix=prefix, dir=self.tmpdir.name)
tmpfile3 = os.path.join(tmpdir, "result.html")
cmd_line = (
Expand Down
17 changes: 9 additions & 8 deletions selftests/functional/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import re
import shlex
import tempfile
import unittest
from xml.dom import minidom

Expand Down Expand Up @@ -362,7 +361,7 @@ def test_output_incompatible_setup(self):
)

def test_output_compatible_setup(self):
tmpfile = tempfile.mktemp(dir=self.tmpdir.name)
tmpfile = os.path.join(self.tmpdir.name, f"avocado_{__name__}.xml")
cmd_line = (
f"{AVOCADO} run --job-results-dir {self.tmpdir.name} "
f"--disable-sysinfo --journal --xunit {tmpfile} "
Expand All @@ -380,7 +379,7 @@ def test_output_compatible_setup(self):
minidom.parse(tmpfile)

def test_output_compatible_setup_2(self):
tmpfile = tempfile.mktemp(dir=self.tmpdir.name)
tmpfile = os.path.join(self.tmpdir.name, f"avocado_{__name__}.json")
cmd_line = (
f"{AVOCADO} run --job-results-dir {self.tmpdir.name} "
f"--disable-sysinfo --xunit - --json {tmpfile} "
Expand All @@ -401,8 +400,8 @@ def test_output_compatible_setup_2(self):
minidom.parseString(result.stdout_text)

def test_output_compatible_setup_nooutput(self):
tmpfile = tempfile.mktemp(dir=self.tmpdir.name)
tmpfile2 = tempfile.mktemp(dir=self.tmpdir.name)
tmpfile = os.path.join(self.tmpdir.name, f"avocado_{__name__}.xml")
tmpfile2 = os.path.join(self.tmpdir.name, f"avocado_{__name__}.json")
# Verify --show=none can be supplied as app argument
cmd_line = (
f"{AVOCADO} --show=none run "
Expand Down Expand Up @@ -490,7 +489,7 @@ def test_silent_trumps_test(self):
self.assertEqual(result.stdout, b"")

def test_verify_whiteboard_save(self):
tmpfile = tempfile.mktemp(dir=self.tmpdir.name)
tmpfile = os.path.join(self.tmpdir.name, f"avocado_{__name__}.json")
config = os.path.join(self.tmpdir.name, "conf.ini")
content = (
"[datadir.paths]\nlogs_dir = %s" # pylint: disable=C0209
Expand Down Expand Up @@ -527,7 +526,7 @@ def test_verify_whiteboard_save(self):
)

def test_gendata(self):
tmpfile = tempfile.mktemp(dir=self.tmpdir.name)
tmpfile = os.path.join(self.tmpdir.name, f"avocado_{__name__}.json")
cmd_line = (
f"{AVOCADO} run --job-results-dir {self.tmpdir.name} "
f"--disable-sysinfo "
Expand Down Expand Up @@ -555,7 +554,9 @@ def test_gendata(self):
)

def test_redirect_output(self):
redirected_output_path = tempfile.mktemp(dir=self.tmpdir.name)
redirected_output_path = os.path.join(
self.tmpdir.name, f"avocado_{__name__}_output"
)
cmd_line = (
f"{AVOCADO} run --job-results-dir {self.tmpdir.name} "
f"--disable-sysinfo examples/tests/passtest.py > {redirected_output_path}"
Expand Down

0 comments on commit ab0107f

Please sign in to comment.