shibosoftwaredev/f1c100s-linux-nema17-stepper-controller

A four-layer NEMA 17 motor-controller PCB combining an Allwinner F1C100S Linux computer, USB‑PD/buck power system, W5500 Ethernet, STM32 real-time motion control, DRV8825 stepper driver, protection/temperature/current telemetry, USB interfaces, and local LED/buzzer diagnostics.

Version
0.4.56
License
unset
Stars
0

scripts/check-software-current-module.mjs

import fs from "node:fs"
import path from "node:path"
import os from "node:os"
import crypto from "node:crypto"
import assert from "node:assert/strict"
import {spawnSync} from "node:child_process"
const baseline=path.resolve("../../work/nema17-clean-schematic-v054-IAQpFd")
const hash=p=>crypto.createHash("sha256").update(fs.readFileSync(p)).digest("hex")
function files(directory) {
  return fs.readdirSync(directory,{withFileTypes:true}).flatMap(e=>{
    if(["node_modules","dist","reports","build",".DS_Store"].includes(e.name))return []
    const p=path.join(directory,e.name)
    return e.isDirectory()?files(p):[p]
  })
}
const original=files(path.join(baseline,"modules")),current=files("modules")
const relative=original.map(p=>path.relative(baseline,p)).sort()
assert.deepEqual(current.sort(),relative,"same complete stored-module file set as v0.4.55")
for(const p of relative)assert.equal(hash(p),hash(path.join(baseline,p)),p)
const scratch=fs.mkdtempSync(path.join(os.tmpdir(),"nema17-v055-module-test-"))
fs.cpSync(path.join(baseline,"modules"),path.join(scratch,"modules"),{recursive:true})
fs.symlinkSync(fs.realpathSync("node_modules"),path.join(scratch,"node_modules"),"dir")
const result=spawnSync(process.execPath,["test","./modules/f1c100s/tests"],{cwd:scratch,encoding:"utf8",maxBuffer:20*1024*1024})
if(result.error)throw result.error
const baselineLog="reports/software-current-baseline-module-tests.log"
fs.writeFileSync(baselineLog,result.stdout+result.stderr)
const cases=p=>{
  const text=fs.readFileSync(p,"utf8")
  assert.match(text,/Ran 32 tests across 2 files\./)
  const passed=[...text.matchAll(/^\(pass\) (.+) \[[^\]]+\]$/gm)].map(m=>m[1]).sort()
  const failed=[...text.matchAll(/^\(fail\) (.+) \[[^\]]+\]$/gm)].map(m=>m[1]).sort()
  assert.equal(passed.length+failed.length,32)
  return {passed,failed}
}
const a=cases(baselineLog),b=cases("reports/current-module-tests.log")
assert.deepEqual(b,a,"same outcomes against an isolated copy of the actual v0.4.55 modules")
assert.equal(result.status,0)
assert.deepEqual(b.failed,[])
const report={status:"PASS",unchangedPublishedRuntimeFiles:relative.length,
  baselinePassed:a.passed.length,baselineFailed:a.failed.length,currentPassed:b.passed.length,currentFailed:b.failed.length,
  addedFailures:0,baselineSource:baseline,isolatedBaseline:scratch,
  evidence:Object.fromEntries([baselineLog,"reports/current-module-tests.log"].map(p=>[p,hash(p)]))}
fs.writeFileSync("reports/module-test-regression.json",JSON.stringify(report,null,2)+"\n")
console.log(JSON.stringify(report))