Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
cff-version: 1.2.0
message: "If you use this software, please cite it using the metadata from this file."
title: "cliffvm"
type: software
authors:
- given-names: "Dmitrii O."
family-names: "Chechetkin"
repository-code: "https://github.com/chedim/cliffvm"
license: MIT
abstract: >-
cliffvm is the cliffhanger VM: a reactive graph of entities with getters and
setters, a SQLite store, an HTTP door and drivers. It is the engine of babyseat,
an AI seat whose memory is a graph the model programs; the behaviour is written
in c1f packs and the engine is only the host.
keywords:
- virtual machine
- reactive graph
- entity graph
- memory
- LLM
38 changes: 38 additions & 0 deletions tests/citation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//! The citation file (CITATION.cff): what Zenodo and GitHub read for the project's citation. It names the project and its repository, its license is the
//! crate's, and a `version` in it (written at the release commit, with `date-released`) is the crate's version.
use std::path::Path;

fn read(path: &Path) -> String { std::fs::read_to_string(path).unwrap_or_else(|e| panic!("{}: {e}", path.display())) }

/// The value of a top-level `key: value` line, without quotes.
fn field(text: &str, key: &str) -> Option<String> {
text.lines().find_map(|l| l.strip_prefix(&format!("{key}:")).map(|v| v.trim().trim_matches('"').to_string()))
}

const REPO: &str = "cliffvm";

fn root() -> &'static Path { Path::new(env!("CARGO_MANIFEST_DIR")) }

#[test]
fn the_citation_file_names_the_project_its_repository_and_its_license() {
let c = read(&root().join("CITATION.cff"));
assert_eq!(field(&c, "cff-version").as_deref(), Some("1.2.0"));
assert_eq!(field(&c, "type").as_deref(), Some("software"));
assert_eq!(field(&c, "title").as_deref(), Some(REPO));
assert_eq!(field(&c, "repository-code").as_deref(), Some(format!("https://github.com/chedim/{REPO}").as_str()));
assert!(c.lines().any(|l| l == "authors:"), "authors are required");
assert!(field(&c, "message").is_some(), "a message");
assert!(c.lines().any(|l| l.starts_with("abstract:")), "an abstract");
let cargo = read(&root().join("Cargo.toml"));
assert!(cargo.lines().any(|l| l.trim() == format!("license = \"{}\"", field(&c, "license").unwrap())), "the license is the crate's");
}

#[test]
fn a_version_in_the_citation_file_is_the_crates_version() {
let c = read(&root().join("CITATION.cff"));
let Some(v) = field(&c, "version") else { return }; // written at the release commit
let cargo = read(&root().join("Cargo.toml"));
let crate_v = cargo.lines().find_map(|l| l.strip_prefix("version = ").map(|v| v.trim_matches('"').to_string())).expect("a version in Cargo.toml");
assert_eq!(v, crate_v);
assert!(field(&c, "date-released").is_some(), "a version comes with its date");
}
Loading