From d137d3342c036e04bf3725946ea48357556784f7 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Thu, 8 Jun 2023 17:14:23 -0400 Subject: [PATCH] meta: Add tests Tests help guarantee that I don't forget to do something that I should have done, such as importing a certain nix module. --- modules/fish-starship/default.nix | 3 ++- tests/main.cr | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/main.cr diff --git a/modules/fish-starship/default.nix b/modules/fish-starship/default.nix index dbf74bd6..6abe4a8c 100644 --- a/modules/fish-starship/default.nix +++ b/modules/fish-starship/default.nix @@ -61,7 +61,8 @@ in { utf16 = "recode utf16..utf8"; # Rarely, some files from Japan are utf16 instead jp = "LANG=ja_JP.UTF-8 LC_ALL=ja_JP.UTF-8"; vm = "cd ~/nix-config && nixos-rebuild build-vm --flake . && ./result/bin/run-${VARIABLES.hostname}-vm && trash put result ${VARIABLES.hostname}.qcow2"; - sw = "cd ~/nix-config && sudo nixos-rebuild switch --flake ."; + sw = "cd ~/nix-config && crystal run tests/main.cr --progress && sudo nixos-rebuild switch --flake ."; + st = "cd ~/nix-config && crystal run tests/main.cr --progress"; c = "tput reset"; # Clear the terminal completely e = "exit"; diff --git a/tests/main.cr b/tests/main.cr new file mode 100644 index 00000000..5cfbe61a --- /dev/null +++ b/tests/main.cr @@ -0,0 +1,16 @@ +require "spec" +require "colorize" + +describe "nix-config" do + it "includes all modules" do + all_modules = Dir.children("modules") + all_modules.delete("default.nix") + modules = File.read("./modules/default.nix") + + all_modules.each do |current_module| + print "Checking ./modules/#{current_module}...".colorize(:blue) + modules.includes?("./#{current_module}").should be_true + puts "✓".colorize(:green) + end + end +end