diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2553347..a1d3f38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,7 +18,7 @@ jobs: uses: actions/cache@v4 with: path: test/gamescripts - key: rpu-and-modderpack-gamescripts-v1004 + key: rpu-and-modderpack-gamescripts-v1006 - name: Download RPU scripts & modderspack if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') @@ -97,7 +97,7 @@ jobs: uses: actions/cache@v4 with: path: test/gamescripts - key: rpu-and-modderpack-gamescripts-v1004 + key: rpu-and-modderpack-gamescripts-v1006 - name: Download RPU scripts & modderspack if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') shell: bash @@ -234,7 +234,7 @@ jobs: if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') with: path: test/gamescripts - key: rpu-and-modderpack-gamescripts-v1004 + key: rpu-and-modderpack-gamescripts-v1006 fail-on-cache-miss: true - name: Test on Fallout RPU if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') @@ -249,9 +249,18 @@ jobs: path: build/bin/** build_linux: - name: Linux build + name: Linux build (${{ matrix.arch }}) runs-on: ubuntu-22.04 - needs: [setup_rpu_tests] + needs: [setup_rpu_tests] + strategy: + matrix: + include: + - arch: x86 + cmake_flags: "" + artifact_name: linux-x86 + - arch: x64 + cmake_flags: "-DFORCE_32BIT=OFF" + artifact_name: linux-x64 defaults: run: shell: bash @@ -260,6 +269,7 @@ jobs: uses: actions/checkout@v4 - name: Dependencies (x86) + if: matrix.arch == 'x86' run: | sudo dpkg --add-architecture i386 sudo apt update @@ -269,7 +279,51 @@ jobs: run: | mkdir out cd out - cmake .. + cmake ${{ matrix.cmake_flags }} .. + make + + - name: Test + shell: bash + run: | + export SSLC=../out/bin/sslc + (cd test && bash ./tests.bash) + + - name: Get cache RPU & modderspack + uses: actions/cache@v4 + if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') + with: + path: test/gamescripts + key: rpu-and-modderpack-gamescripts-v1006 + fail-on-cache-miss: true + - name: Test on Fallout RPU + if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') + run: | + export SSLC=../out/bin/sslc + (cd test && bash ./test_on_fallout2_rpu_run.bash) + + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.artifact_name }} + path: out/bin/** + retention-days: 7 + + build_macos: + name: macOS build (x64) + runs-on: macos-latest + needs: [setup_rpu_tests] + defaults: + run: + shell: bash + steps: + - name: Clone + uses: actions/checkout@v4 + + - name: Configure & build + run: | + mkdir out + cd out + cmake -DFORCE_32BIT=OFF .. make - name: Test @@ -283,7 +337,7 @@ jobs: if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') with: path: test/gamescripts - key: rpu-and-modderpack-gamescripts-v1004 + key: rpu-and-modderpack-gamescripts-v1006 fail-on-cache-miss: true - name: Test on Fallout RPU if: github.event_name == 'pull_request' && !contains(github.event.pull_request.labels.*.name, 'skip-rpu-check') @@ -294,14 +348,14 @@ jobs: - name: Upload uses: actions/upload-artifact@v4 with: - name: linux + name: macos-x64 path: out/bin/** retention-days: 7 release: if: github.event_name == 'push' runs-on: ubuntu-22.04 - needs: [build_windows, build_linux, build_emscripten] + needs: [build_windows, build_linux, build_macos, build_emscripten] permissions: write-all steps: - name: Download all artifacts @@ -330,8 +384,14 @@ jobs: mv windows-release-dll/Build/parser.dll parser.dll rm -rf windows-release-dll - mv linux/sslc sslc-linux - rm -rf linux + mv linux-x86/sslc sslc-linux-x86 + rm -rf linux-x86 + + mv linux-x64/sslc sslc-linux-x64 + rm -rf linux-x64 + + mv macos-x64/sslc sslc-macos-x64 + rm -rf macos-x64 ls -laR diff --git a/CMakeLists.txt b/CMakeLists.txt index f6d01d2..6935f53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,15 @@ set(EXECUTABLE_NAME sslc) project(${EXECUTABLE_NAME}) -# Set 32-bit flag for all targets because it segfaults on 64-bit -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") +option(FORCE_32BIT "Force 32-bit build" ON) + +if(FORCE_32BIT AND APPLE) + message(FATAL_ERROR "Unable to compile 32-bit on Apple") +endif() + +if(FORCE_32BIT) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") +endif() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) diff --git a/compat.h b/compat.h index a62f219..4015aab 100644 --- a/compat.h +++ b/compat.h @@ -43,7 +43,7 @@ int strcat_s(char *dest, size_t destsz, const char *src); #define _stat stat -#if !defined(__EMSCRIPTEN__) +#if defined(__linux__) && !defined(__EMSCRIPTEN__) typedef __time_t time_t; #endif diff --git a/compile.c b/compile.c index 6dfe866..606abb0 100644 --- a/compile.c +++ b/compile.c @@ -33,7 +33,7 @@ FILE *parseroutput; #define FINDFIRST(x, y) _findfirst(x, y) #define FINDNEXT(x, y) _findnext(x, y) #define FINDCLOSE(x, y) _findclose(x) -#define FINDHANDLE long +#define FINDHANDLE intptr_t //#define BAD_HANDLE -1 #if defined(_MSC_VER) diff --git a/gencode.c b/gencode.c index d412077..39580f1 100644 --- a/gencode.c +++ b/gencode.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "parse.h" #include "parselib.h" @@ -53,22 +54,22 @@ static void writeWord(unsigned short a, FILE *f) { writeByte((unsigned char)(a & 0x00ff), f); } -static void writeLong(unsigned long a, FILE *f) { +static void writeLong(uint32_t a, FILE *f) { writeWord((unsigned short)(a >> 16), f); writeWord((unsigned short)(a & 0x0000ffff), f); } -void writeInt(unsigned long a, FILE *f) { +void writeInt(uint32_t a, FILE *f) { writeWord(O_INTOP, f); writeLong(a, f); } void writeFloat(float a, FILE *f) { writeWord(O_FLOATOP, f); - writeLong(*(unsigned long *)&a, f); + writeLong(*(uint32_t *)&a, f); } -void writeString(unsigned long a, FILE *f) { +void writeString(uint32_t a, FILE *f) { writeWord(O_STRINGOP, f); writeLong(a, f); } @@ -84,7 +85,7 @@ static void writeMemory(unsigned char *p, int len, FILE *f) { static void writenamelist(FILE *f, char *namelist) { if (namelist) { int len; - writeLong(*(unsigned long *)namelist, f); + writeLong(*(unsigned int *)namelist, f); namelist += 4; while((len = *(unsigned short *)namelist) != 0xffff) { writeWord((unsigned short)len, f); @@ -696,7 +697,7 @@ static int writeStatement(NodeList *n, int i, FILE *f) { patchOffset(trueAddr+OPCODE_SIZE, outputTell(f), f); } else { - unsigned long a = outputTell(f); + int a = outputTell(f); patchOffset(falseAddr+OPCODE_SIZE, a, f); } diff --git a/gencode.h b/gencode.h index fbad855..70944c2 100644 --- a/gencode.h +++ b/gencode.h @@ -1,6 +1,8 @@ #ifndef _GENCODE_H_ #define _GENCODE_H_ +#include + extern void generateCode(Program *, const char *); extern int writeNumExpression(NodeList *n, int i, int num, FILE *f); @@ -8,9 +10,9 @@ extern int writeExpression(NodeList *n, int i, FILE *f); extern int writeExpressionProc(NodeList *n, int i, FILE *f); extern int writeNumExpressionProc(NodeList *n, int i, int num, FILE *f); extern void writeOp(unsigned short op, FILE *f); -extern void writeInt(unsigned long a, FILE *f); +extern void writeInt(uint32_t a, FILE *f); extern void writeFloat(float a, FILE *f); -extern void writeString(unsigned long a, FILE *f); +extern void writeString(uint32_t a, FILE *f); extern int writeBlock(NodeList *n, int i, FILE *f); -#endif \ No newline at end of file +#endif diff --git a/lex.c b/lex.c index 1a1527e..d450aab 100644 --- a/lex.c +++ b/lex.c @@ -47,11 +47,11 @@ static int fileNameSize=0; static char **fileNames=0; const char *AddFileName(const char *c) { if(fileNameSize==0) { - fileNames=(char**)malloc(8*4); + fileNames=(char**)malloc(8*sizeof(char*)); fileNameSize=8; } else if(numFileNames==fileNameSize-1) { fileNameSize+=8; - fileNames=(char**)realloc(fileNames, fileNameSize*4); + fileNames=(char**)realloc(fileNames, fileNameSize*sizeof(char*)); } fileNames[numFileNames]=(char*)malloc(strlen(c)+1); strcpy(fileNames[numFileNames], c); diff --git a/mcpp_support.c b/mcpp_support.c index 13a28b7..5c39bf2 100644 --- a/mcpp_support.c +++ b/mcpp_support.c @@ -1111,7 +1111,7 @@ int get_ch( void) * Always return the value representable by unsigned char. */ { - int len; + size_t len; int c; FILEINFO * file; @@ -1186,7 +1186,7 @@ int get_ch( void) infile->fp = fopen( cur_fullname, "r"); fseek( infile->fp, infile->pos, SEEK_SET); } /* Re-open the includer and restore the file-position */ - len = (int) (infile->bptr - infile->buffer); + len = infile->bptr - infile->buffer; infile->buffer = (char*)realloc( infile->buffer, NBUFF); /* Restore full size buffer to get the next line */ infile->bptr = infile->buffer + len; diff --git a/mcpp_system.c b/mcpp_system.c index db0f2c2..c55ec11 100644 --- a/mcpp_system.c +++ b/mcpp_system.c @@ -1042,7 +1042,7 @@ static int open_file( { char dir_fname[ PATHMAX] = { EOS, }; static int max_open; - int len; + size_t len; FILEINFO * file = infile; FILE * fp; char * fullname; @@ -1088,7 +1088,7 @@ static int open_file( } else if (fp == NULL) /* No read permission */ goto _false; /* Truncate buffer of the includer to save memory */ - len = (int) (file->bptr - file->buffer); + len = file->bptr - file->buffer; if (len) { file->buffer = xrealloc( file->buffer, len + 1); file->bptr = file->buffer + len; diff --git a/noconfig.h b/noconfig.h index 05833b6..bb5a85a 100644 --- a/noconfig.h +++ b/noconfig.h @@ -174,8 +174,12 @@ #endif #ifndef HOST_HAVE_STPCPY +#if defined(__APPLE__) +#define HOST_HAVE_STPCPY TRUE +#else #define HOST_HAVE_STPCPY FALSE #endif +#endif /* * Declaration of standard library functions and macros. diff --git a/optimize.c b/optimize.c index c92474a..a476a78 100644 --- a/optimize.c +++ b/optimize.c @@ -391,7 +391,7 @@ static int ConstantPropagateExpression(Node* nodes, Variable* vars, Value* value } static int* FindAssignmentsInBlock(const Node* nodes, const Variable* vars, int varCount) { - int* results = (int*)calloc(1, varCount * 4); + int* results = (int*)calloc(1, varCount * sizeof(int)); int statementdepth = 1, var; assert(nodes->token == T_START_STATEMENT); while (statementdepth) { @@ -719,7 +719,7 @@ static void VariableReuse(NodeList* _nodes, VariableList* vars, int numArgs, Var static void DeadVariableRemoval(NodeList* _nodes, VariableList* vars, int numArgs) { int i, var, j; Node* nodes = _nodes->nodes; - int *uses = (int*)calloc(1, vars->numVariables * 4); + int *uses = (int*)calloc(1, vars->numVariables * sizeof(int)); for (i = 0; i < vars->numVariables; i++) uses[i] = 0; for (i = 0; i < _nodes->numNodes; i++) { if (nodes[i].token == T_SYMBOL && (var = LookupVariable(&nodes[i])) != -1) { @@ -1114,16 +1114,16 @@ static void GetNamelistData(char* namelist, int* outEntries, char** outEndptr, i list += *(unsigned short*)list + 2; } endptr = list + 2; - refs = (int*)calloc(1, entries * 4); - offsets = (int*)malloc(entries * 4); - transforms = (int*)malloc(entries * 4); + refs = (int*)calloc(1, entries * sizeof(int)); + offsets = (int*)malloc(entries * sizeof(int)); + transforms = (int*)malloc(entries * sizeof(int)); //first find the offsets list = namelist + 4; for (i = 0; i < entries; i++) { - offsets[i] = 2 + (unsigned int)list - (unsigned int)namelist; + offsets[i] = 2 + (int)(list - namelist); list += *(unsigned short*)list + 2; } - memcpy(transforms, offsets, entries * 4); + memcpy(transforms, offsets, entries * sizeof(int)); *outEntries = entries; *outEndptr = endptr; diff --git a/parse.c b/parse.c index 967f0ea..1c6b95a 100644 --- a/parse.c +++ b/parse.c @@ -315,7 +315,7 @@ char *getName(int offset, char *namelist) { */ static int addName(char **namelist, char *name) { unsigned short slen = strlen(name); - long tlen; + unsigned int tlen; char *n = *namelist; char *c; int odd = 0; @@ -328,13 +328,13 @@ static int addName(char **namelist, char *name) { if (!n) { n = (char*)malloc(4 + 2 + slen + 2); - *(long *)n = 2 + slen; + *(unsigned int *)n = 2 + slen; c = n + 4; } else { int i; - tlen = *(long *)n; + tlen = *(unsigned int *)n; i = findName(n, name); if (i != -1) return i; @@ -346,7 +346,7 @@ static int addName(char **namelist, char *name) { 2 for ending length */ n = (char*)realloc(n, 4 + tlen + 2 + slen + 2); - *(long *)n = tlen + 2 + slen; + *(unsigned int *)n = tlen + 2 + slen; c = n + 4 + tlen; } *(unsigned short *)c = slen; @@ -359,7 +359,7 @@ static int addName(char **namelist, char *name) { static int addString(char **namelist, char *name) { unsigned short slen = strlen(name); - long tlen; + unsigned int tlen; char *n = *namelist; char *c; int odd = 0; @@ -372,13 +372,13 @@ static int addString(char **namelist, char *name) { if (!n) { n = (char*)malloc(4 + 2 + slen + 2); - *(long *)n = 2 + slen; + *(unsigned int *)n = 2 + slen; c = n + 4; } else { int i; - tlen = *(long *)n; + tlen = *(unsigned int *)n; i = findString(n, name); if (i != -1) return i; @@ -390,7 +390,7 @@ static int addString(char **namelist, char *name) { 2 for ending length */ n = (char*)realloc(n, 4 + tlen + 2 + slen + 2); - *(long *)n = tlen + 2 + slen; + *(unsigned int *)n = tlen + 2 + slen; c = n + 4 + tlen; } *(unsigned short *)c = slen; @@ -475,19 +475,19 @@ static void assignVariable(VariableList *v, int which, LexData *what) { v->variables[which].initialized = 1; } -static void reference(int* numrefs, int** refs) { +static void reference(int* numrefs, Reference** refs) { if (!*refs) { - *refs = (int*)malloc(8 * 8); + *refs = (Reference*)malloc(8 * sizeof(Reference)); //#ifndef BUILDING_DLL // Fakels: fixes list of references for sfall Script Editor Ext - } else if (refs[0][numrefs[0] * 2 - 2] == lexGetLineno(currentInputStream) && refs[0][numrefs[0] * 2 - 1] == (int)lexGetFilename(currentInputStream)) { + } else if ((*refs)[*numrefs - 1].line == lexGetLineno(currentInputStream) && (*refs)[*numrefs - 1].file == lexGetFilename(currentInputStream)) { return; //#endif - } else if (!(numrefs[0] % 8)) { - *refs = (int*)realloc(*refs, (numrefs[0] + 9) * 8); + } else if (!(*numrefs % 8)) { + *refs = (Reference*)realloc(*refs, (*numrefs + 9) * sizeof(Reference)); } - refs[0][numrefs[0] * 2] = lexGetLineno(currentInputStream); - refs[0][numrefs[0] * 2 + 1] = (int)lexGetFilename(currentInputStream); - numrefs[0]++; + (*refs)[*numrefs].line = lexGetLineno(currentInputStream); + (*refs)[*numrefs].file = lexGetFilename(currentInputStream); + (*numrefs)++; } static void referenceVariable(VariableList *v, int which) { @@ -2076,7 +2076,7 @@ void _stdcall getStringspace(char* data) { memcpy(data, currentProgram->stringspace + 4, size); } void _stdcall getProcRefs(int i, Reference* refs) { - memcpy(refs, currentProgram->procedures.procedures[i + 1].references, currentProgram->procedures.procedures[i + 1].numRefs * 8); + memcpy(refs, currentProgram->procedures.procedures[i + 1].references, currentProgram->procedures.procedures[i + 1].numRefs * sizeof(Reference)); } void _stdcall getVarRefs(int i, Reference* refs) { int numNormalVars = currentProgram->variables.numVariables; @@ -2087,10 +2087,10 @@ void _stdcall getVarRefs(int i, Reference* refs) { } else { varlist = ¤tProgram->variables; } - memcpy(refs, varlist->variables[i].references, varlist->variables[i].numRefs * 8); + memcpy(refs, varlist->variables[i].references, varlist->variables[i].numRefs * sizeof(Reference)); } void _stdcall getProcVarRefs(int i, int j, Reference* refs) { - memcpy(refs, currentProgram->procedures.procedures[i + 1].variables.variables[j].references, currentProgram->procedures.procedures[i + 1].variables.variables[j].numRefs * 8); + memcpy(refs, currentProgram->procedures.procedures[i + 1].variables.variables[j].references, currentProgram->procedures.procedures[i + 1].variables.variables[j].numRefs * sizeof(Reference)); } diff --git a/parse.h b/parse.h index 28e2367..0dfe752 100644 --- a/parse.h +++ b/parse.h @@ -26,13 +26,14 @@ typedef struct { }; } Value; -#ifdef BUILDING_DLL - typedef struct { int line; const char* file; } Reference; +// TODO: 64bit support for Windows DLL +#if defined(BUILDING_DLL) && defined(__cplusplus) +static_assert(sizeof(Reference) == 8, "Reference struct size changed - ABI break"); #endif #define V_LOCAL 1 @@ -41,7 +42,7 @@ typedef struct { #define V_EXPORT 4 typedef struct { int name; /* offset into program or procedure's namelist */ - int* references; + Reference* references; int numRefs; Value value; int type; // this type is where it was declared @@ -89,7 +90,7 @@ typedef struct { int numArgs; int defined; VariableList variables; - int* references; + Reference* references; int numRefs; int uses; int declared; diff --git a/test/test_on_fallout2_rpu_run.bash b/test/test_on_fallout2_rpu_run.bash index 3a70dce..3bed8f0 100755 --- a/test/test_on_fallout2_rpu_run.bash +++ b/test/test_on_fallout2_rpu_run.bash @@ -17,5 +17,5 @@ MODDERPACK_DIR=$(pwd)/modderspack cd Fallout2_Restoration_Project/scripts_src - -run_tests "$SSLC" "$MODDERPACK_DIR/scripting_docs/headers" \ No newline at end of file +sfall_symlink +run_tests "$SSLC" "$MODDERPACK_DIR/scripting_docs/headers" diff --git a/test/test_on_fallout2_rpu_setup.bash b/test/test_on_fallout2_rpu_setup.bash index d17e96d..52f4f35 100755 --- a/test/test_on_fallout2_rpu_setup.bash +++ b/test/test_on_fallout2_rpu_setup.bash @@ -1,6 +1,14 @@ set -e set -u +sedi() { + if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' "$@" + else + sed -i "$@" + fi +} + . utils.bash mkdir -p gamescripts @@ -31,8 +39,8 @@ if [ ! -d 'Fallout2_Restoration_Project' ]; then fi echo "== Fallout2_Restoration_Project scripts removing \r ==" - find . -type f -iname '*.ssl' -exec sed -i 's/\r$//' {} \; - find . -type f -iname '*.h' -exec sed -i 's/\r$//' {} \; + find . -type f -iname '*.ssl' -exec sh -c 'sed "s/\r$//" "$1" > "$1.tmp" && mv "$1.tmp" "$1"' _ {} \; + find . -type f -iname '*.h' -exec sh -c 'sed "s/\r$//" "$1" > "$1.tmp" && mv "$1.tmp" "$1"' _ {} \; echo "Done" else @@ -52,28 +60,19 @@ if [ ! -d 'modderspack' ]; then fi - curl -L https://cyfuture.dl.sourceforge.net/project/sfall/Modders%20pack/modderspack_4.4.6.7z?viasf=1 > modderspack_4.4.6.7z + curl -L https://master.dl.sourceforge.net/project/sfall/Modders%20pack/modderspack_4.4.6.7z?viasf=1 > modderspack_4.4.6.7z 7z x modderspack_4.4.6.7z -omodderspack echo "Done, removing \r" - find modderspack -type f -iname '*.h' -exec sed -i 's/\r$//' {} \; + find modderspack -type f -iname '*.h' -exec sh -c 'sed "s/\r$//" "$1" > "$1.tmp" && mv "$1.tmp" "$1"' _ {} \; echo "Done" else echo "== modderpack already downloaded ==" fi cd Fallout2_Restoration_Project/scripts_src - if [ ! -L 'sfall' ] && [ ! -d 'sfall' ]; then - - # echo "== Creating relative symlink to modderspack headers ==" - # ln -s ../../modderspack/scripting_docs/headers sfall - - echo "== Creating absolute symlink to modderspack headers ==" - ln -s "$MODDERPACK_DIR/scripting_docs/headers" sfall - else - echo "== Symlink to modderspack headers already exists ==" - fi +sfall_symlink cd ../.. diff --git a/test/utils.bash b/test/utils.bash index 72ad586..9d0d6e5 100644 --- a/test/utils.bash +++ b/test/utils.bash @@ -1,6 +1,22 @@ set -e set -u +sedi() { + if [[ "$OSTYPE" == "darwin"* ]]; then + sed -i '' "$@" + else + sed -i "$@" + fi +} + +sfall_symlink() { + local target="../../modderspack/scripting_docs/headers" + if [ -L 'sfall' ]; then + [ "$(readlink sfall)" = "$target" ] || { rm -f sfall && ln -s "$target" sfall; } + elif [ ! -d 'sfall' ]; then + ln -s "$target" sfall + fi +} SSLC_FLAGS="-q -p -l -O2 -d -s -n" @@ -77,10 +93,10 @@ make_test_snapshots() { RETURN_CODE_EXPECTED=$? echo -n "$RETURN_CODE_EXPECTED" > "$FBASE.returncode.expected" set -e - sed -i 's/\r//g' $FBASE.stdout.expected - # sed -i 's#[a-zA-Z0-9\/\:]*/test/gamescripts/Fallout2_Restoration_Project/scripts_src/#/scripts_src/#g' "$FBASE.stdout.expected" # On wine absolute paths can be different - sed -i 's#[a-zA-Z0-9\/\:]*/test/gamescripts/#/#g' "$FBASE.stdout.expected" # On wine absolute paths can be different - sed -i 's#[a-zA-Z0-9\/\:]*/test/embedded/#/#g' "$FBASE.stdout.expected" # On wine absolute paths can be different + sedi 's/\r//g' $FBASE.stdout.expected + # sedi 's#[a-zA-Z0-9\/\:]*/test/gamescripts/Fallout2_Restoration_Project/scripts_src/#/scripts_src/#g' "$FBASE.stdout.expected" # On wine absolute paths can be different + sedi 's#[a-zA-Z0-9\/\:]*/test/gamescripts/#/#g' "$FBASE.stdout.expected" # On wine absolute paths can be different + sedi 's#[a-zA-Z0-9\/\:]*/test/embedded/#/#g' "$FBASE.stdout.expected" # On wine absolute paths can be different echo " Done, return code $RETURN_CODE_EXPECTED" @@ -132,6 +148,7 @@ run_tests() { OLD_PWD=$(pwd) echo "======================= $DIR/$FNAME ========================" cd "$DIR" + rm -f -- *.tmp # Expected build if [ ! -f "$FBASE.returncode.expected" ]; then @@ -146,7 +163,7 @@ run_tests() { EXPECTED_SUCCESSFULL_COMPILED_FILES=$((EXPECTED_SUCCESSFULL_COMPILED_FILES + 1)) fi # On Windows it might checkout files and automatically use CLRF line endings - sed -i 's/\r//g' "$FBASE.stdout.expected" + sedi 's/\r//g' "$FBASE.stdout.expected" # Obvserved build set +e @@ -155,14 +172,19 @@ run_tests() { "$FNAME" -o "$FBASE.int.observed" > "$FBASE.stdout.observed" RETURN_CODE_OBSERVED=$? set -e - sed -i 's/\r//g' "$FBASE.stdout.observed" - sed -i 's#[a-zA-Z0-9\/\:]*/test/gamescripts/#/#g' "$FBASE.stdout.observed" # On wine absolute paths can be different - sed -i 's#[a-zA-Z0-9\/\:]*/test/embedded/#/#g' "$FBASE.stdout.observed" # On wine absolute paths can be different + sedi 's/\r//g' "$FBASE.stdout.observed" + sedi 's#[a-zA-Z0-9\/\:]*/test/gamescripts/#/#g' "$FBASE.stdout.observed" # On wine absolute paths can be different + sedi 's#[a-zA-Z0-9\/\:]*/test/embedded/#/#g' "$FBASE.stdout.observed" # On wine absolute paths can be different if [ "$RETURN_CODE_OBSERVED" -ne "$RETURN_CODE_EXPECTED" ]; then echo " > FAIL: Return code mismatch, want $RETURN_CODE_EXPECTED got $RETURN_CODE_OBSERVED ===" + echo " > Expected stdout:" + cat "$FBASE.stdout.expected" + echo " > Observed stdout:" + cat "$FBASE.stdout.observed" TEST_FAILED_FILES="$TEST_FAILED_FILES$DIR/$FNAME=RETURNCODE$NEW_LINE" TESTS_FAILED_COUNT=$((TESTS_FAILED_COUNT + 1)) + rm -f -- *.tmp else if [ "$RETURN_CODE_EXPECTED" -eq 0 ] && ! diff "$FBASE.int.expected" "$FBASE.int.observed" ; then echo " > FAIL: .INT files mismatch" @@ -179,6 +201,7 @@ run_tests() { echo " > FAIL: Temporary files found, please check the test" TEST_FAILED_FILES="$TEST_FAILED_FILES$DIR/$FNAME=TMPFILES$NEW_LINE" TESTS_FAILED_COUNT=$((TESTS_FAILED_COUNT + 1)) + rm -f -- *.tmp else TESTS_SUCCESS_COUNT=$((TESTS_SUCCESS_COUNT + 1)) echo " > OK" @@ -204,4 +227,4 @@ run_tests() { else echo "=== All tests passed successfully! ===" fi -} \ No newline at end of file +}