1

我非常接近让 Microchip MPLABX MDB(调试器)与称为 ceedling 的自动化测试套件一起工作。我有一个名为sim_test_fixture.rb

该文件用于打开mdb.bat并传递一个名为sim_instructions.txt. 当我运行 ruby​​ 文件时,我得到了一个权限被拒绝的错误。这是为什么?

脚本运行命令"C:\Program Files (x86)\Microchip\MPLABX\v5.05\mplab_platform\bin\"mdb.bat C:\Users\MichaelMi\Documents\SourceTree\LED-Lighting-Driver\test\simulation\sim_instructions.txt 当我自己运行命令时,它工作得很好。只有当我尝试从以下 ruby​​ 文件运行它时,它才会失败。

require 'rbconfig'
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)

OUT_FILE = "./test/simulation/out.txt"
File.delete OUT_FILE if File.exists? OUT_FILE
path = '"C:\Program Files (x86)\Microchip\MPLABX\v5.05\mplab_platform\bin\"mdb.bat C:\Users\MichaelMi\Documents\SourceTree\LED-Lighting-Driver\test\simulation\sim_instructions.txt'
var = IO.popen(path)
Process.wait
if File.exists? OUT_FILE
    file_contents = File.read OUT_FILE
    file_contents.gsub!("\n", "")
    print file_contents
end 
4

1 回答 1

1

我不是 100% 确定差异,但这段代码有效!

require 'rbconfig'
is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
OUT_FILE = "./test/simulation/out.txt"
File.delete OUT_FILE if File.exists? OUT_FILE
if is_windows
    path = '"C:\\Program Files (x86)\\Microchip\\MPLABX\\v5.05"'
    var = IO.popen(path + "\\mplab_platform\\bin\\mdb.bat ./test/simulation/sim_instructions.txt > " + OUT_FILE)
else
    var = IO.popen("#{ENV['MPLABX_ROOT']}mplab_ide/bin/mdb.sh ./test/simulation/sim_instructions.txt > " + OUT_FILE)
end
Process.wait
if File.exists? OUT_FILE
    file_contents = File.read OUT_FILE
    print file_contents
end
于 2019-10-16T19:38:14.447 回答