Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 2c0a662

Browse files
danmoseleyjanvorli
authored andcommitted
Prevent CMake 2.8 tests failing for unused variable (causing millisec to be dropped from stat calls) (#28573)
* Prevent CMake 2.8 tests failing for unused variable * Make sterror_r test fail as it should * Reenable tests
1 parent 76e8479 commit 2c0a662

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/Native/Unix/configure.cmake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ else ()
2828
endif ()
2929

3030
# We compile with -Werror, so we need to make sure these code fragments compile without warnings.
31-
set(CMAKE_REQUIRED_FLAGS -Werror)
31+
# Older CMake versions (3.8) do not assign the result of their tests, causing unused-value errors
32+
# which are not distinguished from the test failing. So no error for that one.
33+
set(CMAKE_REQUIRED_FLAGS "-Werror -Wno-error=unused-value")
3234

3335
# This compiler warning will fail code as innocuous as:
3436
# static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
@@ -229,7 +231,7 @@ check_c_source_compiles(
229231
int main()
230232
{
231233
char buffer[1];
232-
char* c = strerror_r(0, buffer, 0);
234+
char c = *strerror_r(0, buffer, 0);
233235
return 0;
234236
}
235237
"

src/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ public void TimesIncludeMillisecondPart_Linux()
8686
DateTime time = function.Getter(item);
8787
msec = time.Millisecond;
8888

89-
//if (msec != 0)
90-
// break;
89+
if (msec != 0)
90+
break;
9191

9292
// This case should only happen 1/1000 times, unless the OS/Filesystem does
9393
// not support millisecond granularity.
@@ -98,14 +98,12 @@ public void TimesIncludeMillisecondPart_Linux()
9898
// If it's the OS/Filesystem often returns 0 for the millisecond part, this may
9999
// help prove it. This should only be written 1/1000 runs, unless the test is going to
100100
// fail.
101-
//Console.WriteLine($"TimesIncludeMillisecondPart got a file time of {time.ToString("o")}");
102101
Console.WriteLine($"## TimesIncludeMillisecondPart got a file time of {time.ToString("o")} on {driveFormat}");
103102

104103
item = GetExistingItem(); // try a new file/directory
105104
}
106105

107-
// Temporarily disabled while investigating failures in #27662
108-
// Assert.NotEqual(0, msec);
106+
Assert.NotEqual(0, msec);
109107
});
110108
}
111109

@@ -131,11 +129,6 @@ public void TimesIncludeMillisecondPart_Windows()
131129
// If it's 1/1000, or low granularity, this may help:
132130
Thread.Sleep(1234);
133131

134-
// If it's the OS/Filesystem often returns 0 for the millisecond part, this may
135-
// help prove it. This should only be written 1/1000 runs, unless the test is going to
136-
// fail.
137-
Console.WriteLine($"TimesIncludeMillisecondPart got a file time of {time.ToString("o")}");
138-
139132
item = GetExistingItem(); // try a new file/directory
140133
}
141134

0 commit comments

Comments
 (0)