Skip to content

Commit

Permalink
Fix windows tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Dec 3, 2023
1 parent 32278ef commit 6ba7929
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,4 @@ Known Limitations

- Limited path and filename sizes
- [Possible race condition bug if folder being read has changing content](https://github.com/cxong/tinydir/issues/13)
- Does not support extended-length path lengths in Windows - paths are limited to 260 characters. See <https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry>
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Win32/
*.vcxproj.filters
*.VC.*
*.sln
.vs/

# Linux
Makefile
Expand Down
16 changes: 13 additions & 3 deletions tests/cbehave/cbehave.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,23 @@ void cbehave_feature_exit(void *old_state, void *state) {
void cbehave_feature_return(const char *file, int line, int ret, void *state) {
cbehave_state *cur = (cbehave_state*)state;

cur->failed_scenarios++;
if (ret == 0)
{
setColor(YELLOW);
printf("\t\t\t%s:%d: Skipping feature due to failed assertion.\n",
file,
line);
}
else
{
cur->failed_scenarios++;

setColor(RED);
printf("\t\t\t%s:%d: Exception occurred, error code: %d.\n",
setColor(RED);
printf("\t\t\t%s:%d: Exception occurred, error code: %d.\n",
file,
line,
ret);
}
setColor(DEFAULT_COLOR);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/file_open_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ FEATURE(file_open, "File open")
make_temp_dir("temp_dir_", folder);
ASSERT(strlen(folder) > 0, 1);
strcat(folder, "/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
mkdir(folder, 0700);
ASSERT(mkdir(folder, 0700) == 0, 0);
strcat(folder, "/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
mkdir(folder, 0700);
ASSERT(mkdir(folder, 0700) == 0, 0);
WHEN("we open it")
tinydir_file file;
int r = tinydir_file_open(&file, folder);
Expand Down
7 changes: 7 additions & 0 deletions tests/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,10 @@

void make_temp_file(const char *prefix, char *out);
void make_temp_dir(const char *prefix, char *out);

#ifdef _MSC_VER
#include <direct.h>
#define mkdir(p, a) _mkdir(p)
#elif defined(_WIN32)
#define mkdir(p, a) mkdir(p)
#endif

0 comments on commit 6ba7929

Please sign in to comment.