From c0bcb07a807229e08aa19b25456104462cb986f0 Mon Sep 17 00:00:00 2001 From: j178 <10510431+j178@users.noreply.github.com> Date: Wed, 24 Jan 2024 19:19:06 +0800 Subject: [PATCH] fix: give more time for first execution of the binary --- lang/test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lang/test.go b/lang/test.go index 25c5a837..d33cb26c 100644 --- a/lang/test.go +++ b/lang/test.go @@ -186,7 +186,13 @@ func runTest(q *leetcode.QuestionData, genResult *GenerateResult, args []string, return } ran++ - ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) + timeout := 3 * time.Second + if ran == 1 { + // Give more time for the first run. + // On macOS, first time execution of a binary may be slow due to the system's security check. + timeout += 3 * time.Second + } + ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() outputBuf := new(strings.Builder)