mirror of
https://github.com/donovanglover/nix-config.git
synced 2024-11-22 00:03:55 +01:00
meta: Begin re-writing tests in TypeScript/Deno
2 months ago, I figured out how to make Crystal work on NixOS and made an upstream PR to fix Crystal being unable to find -lpcre. Unfortunately, that change hasn't been merged yet and I even encountered a core dumped error when trying to build Crystal myself recently. Although people may be busy, I am concerned about the popularity of Crystal relative to other languages. It could be the case that the build was broken for so long precisely because no one used Crystal, and that the language isn't popular enough to generate comments on the patch either. In any case, JavaScript/TypeScript is here to stay, and it certainly has better tooling and community support than Crystal at the moment. Deno has been going strong for a few years now, and now that I know Rust, I can also contribute to it if I want to.
This commit is contained in:
parent
41b784ec9b
commit
fb7694a844
@ -1,7 +0,0 @@
|
||||
require "./check_top_level_imports"
|
||||
|
||||
check_top_level_imports("containers")
|
||||
check_top_level_imports("home")
|
||||
check_top_level_imports("modules")
|
||||
check_top_level_imports("overlays")
|
||||
check_top_level_imports("specializations")
|
41
tests/main.ts
Normal file
41
tests/main.ts
Normal file
@ -0,0 +1,41 @@
|
||||
import { assert } from "https://deno.land/std@0.200.0/assert/mod.ts";
|
||||
import { walk } from "https://deno.land/std@0.200.0/fs/walk.ts";
|
||||
|
||||
const getFilesInDirectory = async (directory: string): Promise<string[]> => {
|
||||
const files = [];
|
||||
|
||||
for await (const walkEntry of walk(directory)) {
|
||||
if (walkEntry.isFile) {
|
||||
if (walkEntry.path.includes("default.nix")) continue
|
||||
files.push(walkEntry.path)
|
||||
}
|
||||
}
|
||||
|
||||
return files
|
||||
}
|
||||
|
||||
const getImportsInFile = async (file: string): Promise<string[]> => {
|
||||
const text = await Deno.readTextFile(file);
|
||||
const lines = text.split("\n")
|
||||
const imports = [];
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (lines[i].includes("./")) {
|
||||
imports.push(file.split("./")[1].split("/")[0] + "/" + lines[i].split("./")[1].split(" ")[0])
|
||||
}
|
||||
}
|
||||
|
||||
return imports
|
||||
}
|
||||
|
||||
Deno.test("imports all modules in ./packages", async () => {
|
||||
const packageFiles = await getFilesInDirectory("./packages")
|
||||
const packageImports = await getImportsInFile("./packages/default.nix")
|
||||
|
||||
console.log(packageFiles)
|
||||
console.log(packageImports)
|
||||
|
||||
for (const file of packageFiles) {
|
||||
assert(packageImports.includes(file))
|
||||
}
|
||||
})
|
Loading…
Reference in New Issue
Block a user