xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.82k stars 774 forks source link

xmake test 在windows平台无法正确同时设置多个add_test("test",{run_timeout(1000)}) #5458

Open ZtRXR opened 1 month ago

ZtRXR commented 1 month ago

Xmake 版本

xmake v2.9.4+dev.af3090adb

操作系统版本和架构

Windows11 x86-64 22631.3880 mingw64

描述问题

xmake test 在windows平台无法正确add_test("test",{run_timeout(1000)}) 会出现

error: wait events in poller failed!

linux平台是正常的

期待的结果

在设置的run_timeout()正确kill掉程序并显示结果

工程配置

最小实现如下 lua文件

target("test")
    add_files("./src/*.cpp")
    for v=1,4 do
        local s=tostring(v)
        add_tests(s,files="./src/*.cpp",{run_timeout=10000})
    end

src/main.cpp

#include<bits/stdc++.h>
int main(){
    while(1)getchar();
}

附加信息和错误日志

> xmake test
running tests ...
[ 10%]: running.test P3372/1
[ 20%]: running.test P5431/1
[ 30%]: running.test binExp/binExp
[ 40%]: running.test fperfect/1
[ 50%]: running.test fperfect/2
[ 60%]: running.test fperfect/3
[ 70%]: running.test fperfect/4
[ 80%]: running.test inverse/1
[ 90%]: running.test inverse/2
[100%]: running.test test/1
error: wait events in poller failed!
Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


Title: xmake test cannot correctly add_test("test",{run_timeout(1000)}) on the windows platform

Xmake version

xmake v2.9.4+dev.af3090adb

Operating system version and architecture

Windows11 22631.3880

Describe the problem

xmake test cannot correctly add_test("test",{run_timeout(1000)}) on the windows platform will appear

error: wait events in poller failed!

The linux platform is normal

Expected results

Correctly kill the program and display the results in the set run_timeout()

Project configuration

The minimum implementation is as follows lua file

target("test")
    add_files("./src/*.cpp")
    add_tests("test",{run_timeout=1000})
end

src/main.cpp

#include<bits/stdc++.h>
int main(){
    int n;
    std::cin>>n;
}

Additional information and error logs

> xmake test
running tests...
[10%]: running.test P3372/1
[20%]: running.test P5431/1
[30%]: running.test binExp/binExp
[40%]: running.test fperfect/1
[50%]: running.test fperfect/2
[60%]: running.test fperfect/3
[70%]: running.test fperfect/4
[80%]: running.test inverse/1
[90%]: running.test inverse/2
[100%]: running.test test/1
error: wait events in poller failed!
ZtRXR commented 1 month ago

我更新了一下最小实现,希望作者能修复

Issues-translate-bot commented 1 month ago

Bot detected the issue body's language is not English, translate it automatically.


I updated the minimal implementation, I hope the author can fix it

waruqi commented 4 weeks ago

给个完整工程。

Issues-translate-bot commented 4 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


Give a complete project.

waruqi commented 4 weeks ago

目前的实现,timeout 后,kill process 会导致 WaitForMultipleObjects 直接 failed,不太好搞,需要花时间重新处理下这块的 timeout 逻辑,等后面有时间再看看

https://github.com/xmake-io/xmake/blob/c8e8e04d832288a0a7f4d5a90a89061f7951b0e0/xmake/core/base/os.lua#L895

https://github.com/tboox/tbox/blob/861513a0caec926d62f90dc9839c5a209bf100a5/src/tbox/platform/windows/poller_process.c#L176

Issues-translate-bot commented 4 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


In the current implementation, after timeout, the kill process will cause WaitForMultipleObjects to fail directly, which is not easy to do. You need to spend time to reprocess this timeout logic and look at it later when you have time.

https://github.com/xmake-io/xmake/blob/c8e8e04d832288a0a7f4d5a90a89061f7951b0e0/xmake/core/base/os.lua#L895

https://github.com/tboox/tbox/blob/861513a0caec926d62f90dc9839c5a209bf100a5/src/tbox/platform/windows/poller_process.c#L176

ZtRXR commented 3 weeks ago

最小实现github链接 这里是最小工程项目git仓库

Issues-translate-bot commented 3 weeks ago

Bot detected the issue body's language is not English, translate it automatically.


Minimum implementation github link Here is the minimal project git repository