@@ -14,18 +14,22 @@ local M = {}
1414--- @field test_id string
1515
1616--- @param path string
17- --- @return string content
17+ --- @return boolean success
18+ --- @return string content_or_err
1819local function read_file (path )
1920 local file_fd , open_err = vim .uv .fs_open (path , ' r' , 438 )
20- assert (not open_err , open_err )
21- assert (file_fd , ' expected file descriptor' )
21+ if not file_fd or open_err then
22+ return false , open_err or (' expected file descriptor for ' .. path )
23+ end
2224 local stat , stat_err = vim .uv .fs_fstat (file_fd )
23- assert (not stat_err , stat_err )
24- assert (stat , ' expected file stats' )
25+ if not stat or stat_err then
26+ return false , stat_err or (' expected file stats for ' .. path )
27+ end
2528 local data , read_err = vim .uv .fs_read (file_fd , stat .size , 0 )
26- assert (data , ' expected file content' )
27- assert (not read_err , read_err )
28- return data
29+ if not data or read_err then
30+ return false , read_err or (' expected file content for ' .. path )
31+ end
32+ return true , data
2933end
3034
3135M .execute_command = function (command , args , cwd , opts )
@@ -57,12 +61,12 @@ M.execute_command = function(command, args, cwd, opts)
5761 if is_cargo_test then
5862 diagnostics = require (' rustaceanvim.test' ).parse_cargo_test_diagnostics (output , opts .bufnr )
5963 else
60- local junit_xml = read_file ((cwd or vim .fn .getcwd ()) .. ' /target/nextest/rustaceanvim/junit.xml' )
61- if not junit_xml then
62- vim .notify (' Failed to read junit.xml file' , vim .log .levels .ERROR )
64+ local ok , junit_xml_or_err = read_file ((cwd or vim .fn .getcwd ()) .. ' /target/nextest/rustaceanvim/junit.xml' )
65+ if not ok then
66+ vim .notify (' Failed to read junit.xml file: ' .. junit_xml_or_err , vim .log .levels .ERROR )
6367 return
6468 end
65- diagnostics = require (' rustaceanvim.test' ).parse_nextest_diagnostics (junit_xml , opts .bufnr )
69+ diagnostics = require (' rustaceanvim.test' ).parse_nextest_diagnostics (junit_xml_or_err , opts .bufnr )
6670 end
6771 local summary = get_test_summary (sc .stdout or ' ' )
6872 vim .schedule (function ()
0 commit comments