Skip to content

Instantly share code, notes, and snippets.

@Mte90
Created August 6, 2024 10:04
Show Gist options
  • Save Mte90/5f4ccb36907ff0d6f2f36ed9c499d2c0 to your computer and use it in GitHub Desktop.
Save Mte90/5f4ccb36907ff0d6f2f36ed9c499d2c0 to your computer and use it in GitHub Desktop.
Shellcheck all the stdlib tests
import { split, contains } from "std/text"
import { file_write, file_append, dir_exist, file_exist, create_dir } from "std/fs"
let path = "/tmp/amber-sc-tests"
if (not dir_exist(path)) {
create_dir(path)
}
let report = "{path}/report.txt"
unsafe file_write(report, "Report for Shellcheck")
let output = ""
let stdtests = unsafe $/usr/bin/ls "src/tests/stdlib/"$
let stdlib = split(stdtests, "\n")
loop v in stdlib {
if (not contains(v, ".txt") and file_exist("src/tests/stdlib/{v}")) {
echo "Generating Bash script for test {v}"
unsafe {
unsafe $./target/debug/amber "src/tests/stdlib/{v}" "{path}/{v}.sh"$
output = unsafe $shellcheck "{path}/{v}.sh"$
}
if (status != 0) {
echo "Shellcheck found something!"
unsafe file_append(report, output)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment