Ticket #1171 (new enhancement)

Opened 2 years ago

Last modified 2 years ago

[PATCH] vformat to compile on Windows

Reported by: henrik Owned by: henrik
Priority: low Milestone: Plugin Format: vformat 0.40
Component: Format Plugin: vformat Version: 0.39
Severity: normal Keywords:
Cc:

Description

The vformat/tests/support.c file does not compile on windows (MinGW).

Patch attached.

Any comments?

Attachments

vformat_win32.patch Download (3.2 KB) - added by henrik 2 years ago.

Change History

Changed 2 years ago by henrik

comment:1 Changed 2 years ago by cstender

  • Owner cstender deleted

comment:2 Changed 2 years ago by dgollub

why not using g_mkstemp_full() directly from glib?

comment:3 Changed 2 years ago by henrik

Because it creates a temporary FILE and what we need is a DIRECTORY.

comment:4 Changed 2 years ago by dgollub

  • Owner set to henrik

Try this instead:

char *setup_testbed(const char *fkt_name)
{
#ifndef _WIN32  
        setuid(65534);
#endif
        char *testbed = g_strdup_printf("%s/testbed.XXXXXX", g_get_tmp_dir());
        char *command = NULL, *dirname = NULL;
#ifdef _WIN32
        if(g_file_test(testbed, G_FILE_TEST_IS_DIR))
                destroy_testbed(g_strdup(testbed));

        if(g_mkdir(testbed,0777) < 0){
                        abort();
        }
#else /* WIN32 */
        if (!mkdtemp(testbed))
                abort();
#endif /* WIN32 */

[...]

this is code from OpenSync? trunk: trunk/tests/support.c

Simliar/redudant code ... we should kill this redudant code in near future.

comment:5 Changed 2 years ago by henrik

As far as I can see, this approach would - on WIN32 - use a fixed name for the testbed (testbed.XXXXXX), not a pseudo-random name.

This is bad if you run test-cases in parallel - even if it is for different components (opensync, vformat, ...).

And although the temp directory on WIN32 is normally not shared between users, I don't think there is anything preventing it from being shared between users, which would then also be a problem.

comment:6 Changed 2 years ago by dgollub

  • Priority changed from normal to low

This code is only for unit-testing. Currently i see no reason to run tests in parallel ... This kind of code is only run by continous build hosts or developers - not regular users.

Feel free to replace XXXXX with a random number or so - or lock the directory for windows.

I don't want to introduce too much code from different projects - since we would have to maintain this as well. And we defenitly should try to avoid duplicate code in OpenSync? and vformat.

Since nobody on windows complained about windows temp direcory XXXXX for OpensYnc? testsuite - i doubt someone will for vformat ...

Note: See TracTickets for help on using tickets.