Skip to content

Commit

Permalink
Fix issues related to end of line characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Skptak committed Sep 2, 2023
1 parent a00d181 commit acd8fba
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 139 deletions.
3 changes: 2 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
formatting/filesWithCRLFEndings/* eol=crlf
clang-formatting/filesWithFormattingErrors/* eol=crlf
clang-formatting/filesWithCRLFEndings/* eol=crlf
clang-formatting/filesWithFormattingErrors/testWithFormattingError.c eol=crlf

76 changes: 38 additions & 38 deletions .github/workflows/formattingTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
path: formatting/goodFiles
exclude-dirs: "fileWithErrorInclude, fileWithErrorSource"

formatting-error-cases:
uncrustify-formatting-error-cases:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -295,47 +295,47 @@ jobs:
exit $exitStatus
clang-formatting-success-cases:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- env:
stepName: "Functional | Success | Exclude Files and Dirs"
name: ${{ env.stepName }}
id: exclude-dirs-with-errors
uses: ./clang-formatting
with:
path: clang-formatting/goodFiles
exclude-dirs: "fileWithErrorInclude, fileWithErrorSource"
exclude-files: "formatErrorTest.h, formatErrorTest.c"
- env:
stepName: "Functional | Success | Exclude Files and Dirs"
name: ${{ env.stepName }}
id: exclude-dirs-with-errors
uses: ./clang-formatting
with:
path: clang-formatting/goodFiles
exclude-dirs: "fileWithErrorInclude, fileWithErrorSource"
exclude-files: "formatErrorTest.h, formatErrorTest.c"

- env:
stepName: "Functional | Success | Exclude Just Files"
name: ${{ env.stepName }}
id: exclude-files-with-errors
uses: ./clang-formatting
with:
path: clang-formatting/goodFiles
exclude-dirs: ",,,"
exclude-files: "errorFileInDirectory.h, formatErrorTest.h, errorFileInDirectory.c, formatErrorTest.c"
- env:
stepName: "Functional | Success | Exclude Just Files"
name: ${{ env.stepName }}
id: exclude-files-with-errors
uses: ./clang-formatting
with:
path: clang-formatting/goodFiles
exclude-dirs: ",,,"
exclude-files: "errorFileInDirectory.h, formatErrorTest.h, errorFileInDirectory.c, formatErrorTest.c"

- name: Remove Error Files at Top Directory
working-directory: clang-formatting/goodFiles
shell: bash
run: |
# Remove Error Files at Top Directory
# Do a git remove since we use a git diff to check if formatting fails
git rm $(find . -name "formatErrorTest.c")
git rm $(find . -name "formatErrorTest.h")
- name: Remove Error Files at Top Directory
working-directory: clang-formatting/goodFiles
shell: bash
run: |
# Remove Error Files at Top Directory
# Do a git remove since we use a git diff to check if formatting fails
git rm $(find . -name "formatErrorTest.c")
git rm $(find . -name "formatErrorTest.h")
- env:
stepName: "Functional | Success | Exclude Just Error Dirs"
name: ${{ env.stepName }}
id: exclude-two-files-two-dirs
uses: ./clang-formatting
with:
path: clang-formatting/goodFiles
exclude-dirs: "fileWithErrorInclude, fileWithErrorSource"
- env:
stepName: "Functional | Success | Exclude Just Error Dirs"
name: ${{ env.stepName }}
id: exclude-two-files-two-dirs
uses: ./clang-formatting
with:
path: clang-formatting/goodFiles
exclude-dirs: "fileWithErrorInclude, fileWithErrorSource"

clang-formatting-error-cases:
runs-on: ubuntu-latest
Expand Down
200 changes: 100 additions & 100 deletions clang-formatting/filesWithFormattingErrors/goodFileInHere.c
Original file line number Diff line number Diff line change
@@ -1,100 +1,100 @@
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

typedef struct DateAndTime
{
uint64_t hour;
uint64_t minutes;
uint64_t seconds;
uint64_t msec;
} DateAndTime;

#if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || \
defined( __NT__ ) || defined( WIN64 ) || defined( __WIN64 )
#include <Windows.h>
/* Remove the warning about implicit sleep even with windows.h included */
extern void sleep( int miliseconds );
void getTime( struct DateAndTime * currentTime )
{
SYSTEMTIME st, lt;

GetLocalTime( &lt );
currentTime->hour = lt.wHour;
currentTime->minutes = lt.wMinute;
currentTime->seconds = lt.wSecond;
currentTime->msec = lt.wMilliseconds;
}
#else /* if defined( WIN32 ) || defined ( _WIN32 ) || defined( __WIN32__ ) \
|| defined( __NT__ ) || defined( WIN64 ) || defined( __WIN64 ) */
#include <sys/time.h>
#include <unistd.h>
void getTime( struct DateAndTime * currentTime )
{
struct timeval tv;
struct tm * tm;

gettimeofday( &tv, NULL );
tm = localtime( &tv.tv_sec );
currentTime->hour = tm->tm_hour;
currentTime->minutes = tm->tm_min;
currentTime->seconds = tm->tm_sec;
currentTime->msec = ( int ) ( tv.tv_usec / 1000 );
}
#endif /* if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || \
defined( __NT__ ) || defined( WIN64 ) || defined( __WIN64 ) */

int main( int argc, char ** argv )
{
DateAndTime currentTime = { 0 };
int32_t loop = 0;
int32_t totalLoops = 5U;
int32_t exitCode = 0;

if( argc == 1 )
{
printf( "This is a basic test application .\n" );
printf(
"It prints the date and time and then sleeps for loopCount * 3\n" );
printf( "This program takes in two inputs, a loop count and an exit "
"code\n" );
printf( "By default it will run %d loops and exit with exit status "
"%d\n",
totalLoops,
exitCode );
}

if( argc == 2 )
{
totalLoops = atoi( argv[ 1 ] );
printf( "Will run for requested %d loops\n", totalLoops );
}

if( argc == 3 )
{
exitCode = atoi( argv[ 2 ] );
printf( "Will exit with supplied exit code %d\n", exitCode );
}

setvbuf( stdout, NULL, _IONBF, 0 );

for( int i = 1U; i < totalLoops; i++ )
{
getTime( &currentTime );
printf( "%02llu:%02llu:%02llu.%03llu TEST APPLICATION SLEEPING FOR %d "
"SECONDS\n",
currentTime.hour,
currentTime.minutes,
currentTime.seconds,
currentTime.msec,
i * 3U );
sleep( i * 3U );
}

#ifdef EXIT_WITH_MINUTES
exitCode = currentTime.minutes;
#endif
printf( "EXITING TEST APPLICATION WITH EXIT CODE = %d\n", exitCode );
return exitCode;
}
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

typedef struct DateAndTime
{
uint64_t hour;
uint64_t minutes;
uint64_t seconds;
uint64_t msec;
} DateAndTime;

#if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || \
defined( __NT__ ) || defined( WIN64 ) || defined( __WIN64 )
#include <Windows.h>
/* Remove the warning about implicit sleep even with windows.h included */
extern void sleep( int miliseconds );
void getTime( struct DateAndTime * currentTime )
{
SYSTEMTIME st, lt;

GetLocalTime( &lt );
currentTime->hour = lt.wHour;
currentTime->minutes = lt.wMinute;
currentTime->seconds = lt.wSecond;
currentTime->msec = lt.wMilliseconds;
}
#else /* if defined( WIN32 ) || defined ( _WIN32 ) || defined( __WIN32__ ) \
|| defined( __NT__ ) || defined( WIN64 ) || defined( __WIN64 ) */
#include <sys/time.h>
#include <unistd.h>
void getTime( struct DateAndTime * currentTime )
{
struct timeval tv;
struct tm * tm;

gettimeofday( &tv, NULL );
tm = localtime( &tv.tv_sec );
currentTime->hour = tm->tm_hour;
currentTime->minutes = tm->tm_min;
currentTime->seconds = tm->tm_sec;
currentTime->msec = ( int ) ( tv.tv_usec / 1000 );
}
#endif /* if defined( WIN32 ) || defined( _WIN32 ) || defined( __WIN32__ ) || \
defined( __NT__ ) || defined( WIN64 ) || defined( __WIN64 ) */

int main( int argc, char ** argv )
{
DateAndTime currentTime = { 0 };
int32_t loop = 0;
int32_t totalLoops = 5U;
int32_t exitCode = 0;

if( argc == 1 )
{
printf( "This is a basic test application .\n" );
printf(
"It prints the date and time and then sleeps for loopCount * 3\n" );
printf( "This program takes in two inputs, a loop count and an exit "
"code\n" );
printf( "By default it will run %d loops and exit with exit status "
"%d\n",
totalLoops,
exitCode );
}

if( argc == 2 )
{
totalLoops = atoi( argv[ 1 ] );
printf( "Will run for requested %d loops\n", totalLoops );
}

if( argc == 3 )
{
exitCode = atoi( argv[ 2 ] );
printf( "Will exit with supplied exit code %d\n", exitCode );
}

setvbuf( stdout, NULL, _IONBF, 0 );

for( int i = 1U; i < totalLoops; i++ )
{
getTime( &currentTime );
printf( "%02llu:%02llu:%02llu.%03llu TEST APPLICATION SLEEPING FOR %d "
"SECONDS\n",
currentTime.hour,
currentTime.minutes,
currentTime.seconds,
currentTime.msec,
i * 3U );
sleep( i * 3U );
}

#ifdef EXIT_WITH_MINUTES
exitCode = currentTime.minutes;
#endif
printf( "EXITING TEST APPLICATION WITH EXIT CODE = %d\n", exitCode );
return exitCode;
}

0 comments on commit acd8fba

Please sign in to comment.