Ticket #955 (assigned todo)

Opened 12 years ago

Last modified 11 years ago

need ability to create tempfile from PIR

Reported by: coke Owned by: whiteknight
Priority: normal Milestone:
Component: testing Version:
Severity: medium Keywords: testing newbie
Cc: Language:
Patch status: Platform:

Description

to fully convert tests from Perl to PIR, we need a PIR-level analog to:

    use Parrot::Test::Util 'create_tempfile';

... I'm not sure if we can automatically delete; that would be nice, but a manual deletion at program exit is sufficient.

Change History

Changed 12 years ago by fperrad

a StringHandle PMC could do the job.

Changed 12 years ago by jrtayloriv

What about implementing something like the O_TEMPORARY flag with parrot's open op? (a file opened with the O_TEMPORARY flag is created with a unique name, and will be deleted by the OS when close() is called on the last open file descriptor for the tempfile)

On Linux, this could be done with the mkstemp() function from libc. The PIR syntax could be something like open "template", 't' (see 'man 3 mkstemp' for what I mean by "template")

I think something similar could be implemented for Windows using the GetTempFileName, GetTempFilePath, and CreateFile functions.

Any reasons why this would not be a good way to go about it?

Changed 12 years ago by dukeleto

jrtayloriv++ . Not having to worry about cleaning up temp files and where they go really simplifies test writing.

Changed 12 years ago by dukeleto

Should this be implemented as a dynop?

Changed 12 years ago by jkeenan

  • component changed from none to testing

Changed 11 years ago by cotto

  • keywords newbie added

A dynop would be fine. Implementing it somehow would be great.

Changed 11 years ago by whiteknight

  • status changed from new to assigned
  • owner set to whiteknight

I think we can either add an O_TEMPORARY flag to IO API, or we can add functionality to the OS PMC. I'm going to take a look at some options for this, because I have use for this kind of feature in Rosella, among other places.

Note: See TracTickets for help on using tickets.