tests: Start exploratory design

stable
jaxne 4 years ago
parent 06303a7313
commit dbf7995c57

@ -30,5 +30,9 @@ lib -nologo libcommon.obj
%CompileCommand% %CommonCompilerFlags% ../tests/src/tests.cpp -Fotests.obj -Fmtests.map /link %CommonLinkerFlags% libcommon.lib
robocopy . ..\ libcommon.lib > NUL 2> NUL
del ..\test > NUL 2> NUL
copy tests.exe ..\test > NUL 2> NUL
..\tools\btime.exe --end ePenguin-Software-Framework.aet
popd

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -20,7 +20,8 @@ test "string_test" {
#include <types.h>
#include <shared.h>
#include <tokenizer.h>
#include <tokenizer.cpp>
static string msg_prefix = make_string("[Test Suite] ");
string ReadEntireFileIntoMemory(char* FileName) {
string Result = { };
@ -40,32 +41,96 @@ string ReadEntireFileIntoMemory(char* FileName) {
return Result;
}
#include <string.h>
#include <minwindows.h>
struct lexer_state {
char** FileNames;
u32 FileNameCount;
};
static lexer_state State;
void ListContents(const char* Cwd) {
char Path[MAX_PATH];
_WIN32_FIND_DATAA FindData;
HANDLE FindHandle = INVALID_HANDLE_VALUE;
//Specify a file mask. *.* = We want everything!
sprintf(Path, "%s\\*.*", Cwd);
FindHandle = FindFirstFileA(Path, &FindData);
do {
if (strcmp(FindData.cFileName, ".") != 0 && strcmp(FindData.cFileName, "..") != 0) {
sprintf(Path, "%s\\%s", Cwd, FindData.cFileName);
if (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
ListContents(Path);
}
else if (Substring(Path, "src") != NULL) {
State.FileNames[State.FileNameCount] = (char*)malloc(sizeof(char) * MAX_PATH);
strcpy(State.FileNames[State.FileNameCount], Path);
++State.FileNameCount;
}
}
} while (FindNextFileA(FindHandle, &FindData));
}
int main(char** Args, int ArgCount) {
TCHAR** lppPart = {NULL}; // For GetFullPath :/
char* cwd;
cwd = _getcwd(NULL, 256);
printf("Operating in directory: %s\n\n", cwd);
string Contents = ReadEntireFileIntoMemory("../libcommon/src/shared.h");
tokenizer Tokenizer = Tokenize(Contents, "../libcommon/src/shared.h");
printf("%sTest Suite v0.1\n", msg_prefix.Data);
printf("%sOperating in directory: %s\n\n", msg_prefix.Data, cwd);
// Get the names of the files we will operate on
State.FileNames = (char**)malloc(2048 * sizeof(char*));
if (Substring(cwd, "build")) {
ListContents("..\\tests");
} else {
ListContents("tests");
}
b32 Parsing = true;
while (Parsing) {
token Token = GetToken(&Tokenizer);
switch (Token.Type) {
case Token_EndOfStream: {
Parsing = false;
} break;
for (u32 FileIndex = 0; FileIndex < State.FileNameCount; ++FileIndex) {
char* Filename = State.FileNames[FileIndex];
char* FullFilename = (char*)malloc(MAX_PATH * sizeof(char));
GetFullPathNameA(Filename, MAX_PATH, FullFilename, lppPart);
printf("%s: \n", FullFilename);
case Token_Identifier: {
string Contents = ReadEntireFileIntoMemory(Filename);
tokenizer Tokenizer = Tokenize(Contents, Filename);
} break;
b32 Parsing = true;
while (Parsing) {
token Token = GetToken(&Tokenizer);
switch (Token.Type) {
case Token_EndOfStream: {
Parsing = false;
} break;
case Token_Unknown:
default: {
case Token_Identifier: {
if (StringsMatch(Token.String, "test")) {
GetToken(&Tokenizer);
token Next = GetToken(&Tokenizer);
} break;
}
}
char* TestName = Next.String;
printf(" test '%s'\n", TestName);
}
} break;
case Token_Unknown:
default: {
} break;
}
}
}
return 1;
}
Loading…
Cancel
Save