runtime/plugin_test.js

32 lines
694 B
JavaScript

import rt from 'apigo.cc/gojs/runtime'
import co from 'apigo.cc/gojs/console'
if (!rt.os()) {
co.info('OS: ', rt.os())
return 'os not found'
}
if (!rt.arch()) {
co.info('Arch: ', rt.arch())
return 'arch not found'
}
if (!rt.numCPU()) {
co.info('NumCPU: ', rt.numCPU())
return 'numCPU not found'
}
let goEnv = rt.shell('go "env"')
if (goEnv.join('\n').indexOf('GO111MODULE=') === -1) {
co.info('Go Env: ', goEnv)
return 'failed to get go env by shell'
}
let t1 = new Date().getMilliseconds()
rt.sleep(123)
let t2 = new Date().getMilliseconds()
if (t2 - t1 < 120 || t2 - t1 > 125) {
co.info('sleep time: ', t2 - t1)
return 'sleep failed'
}
return true