Skip to content

Commit 20a8956

Browse files
committed
Don't attempt to update cache entries on Windows.
1 parent 34f1be9 commit 20a8956

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ext/bootsnap/bootsnap.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
#define RB_UNLIKELY(x) (x)
3939
#endif
4040

41+
#ifdef HAVE_FDATASYNC
42+
#define BS_REVALIDATE_CACHE 1
43+
#endif
44+
4145
/*
4246
* An instance of this key is written as the first 64 bytes of each cache file.
4347
* The mtime and size members track whether the file contents have changed, and
@@ -319,7 +323,15 @@ static enum cache_status cache_key_equal_fast_path(struct bs_cache_key *k1,
319323
k1->ruby_platform == k2->ruby_platform &&
320324
k1->compile_option == k2->compile_option &&
321325
k1->ruby_revision == k2->ruby_revision && k1->size == k2->size) {
322-
return (k1->mtime == k2->mtime) ? hit : stale;
326+
if (k1->mtime == k2->mtime) {
327+
return hit;
328+
} else {
329+
#ifdef BS_REVALIDATE_CACHE
330+
return stale;
331+
#else
332+
return miss;
333+
#endif
334+
}
323335
}
324336
return miss;
325337
}

test/compile_cache_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ def test_dont_store_cache_after_a_stale_when_readonly
160160
end
161161

162162
def test_dont_revalidate_when_readonly
163+
skip("Not on Windows") if RUBY_PLATFORM.match?(/mswin|mingw|cygwin/)
164+
163165
path = Help.set_file("a.rb", "a = a = 3", 100)
164166
load(path)
165167

@@ -220,6 +222,8 @@ def test_instrumentation_miss
220222
end
221223

222224
def test_instrumentation_revalidate
225+
skip("Not on Windows") if RUBY_PLATFORM.match?(/mswin|mingw|cygwin/)
226+
223227
file_path = Help.set_file("a.rb", "a = a = 3", 100)
224228
load(file_path)
225229
FileUtils.touch("a.rb", mtime: File.mtime("a.rb") + 42)

0 commit comments

Comments
 (0)