惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
人人都是产品经理
人人都是产品经理
爱范儿
爱范儿
云风的 BLOG
云风的 BLOG
Last Week in AI
Last Week in AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
B
Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
H
Help Net Security
B
Blog RSS Feed
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
N
Netflix TechBlog - Medium
S
SegmentFault 最新的问题
The Cloudflare Blog
I
InfoQ
美团技术团队
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
L
LangChain Blog
A
About on SuperTechFans
T
The Blog of Author Tim Ferriss
Y
Y Combinator Blog

Hacker News

GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis Bonsai 1-bit WebGPU - a Hugging Face Space by webml-community Moving a large-scale metrics pipeline from StatsD to OpenTelemetry / Prometheus GitHub - Nightmare-Eclipse/RedSun: The Red Sun vulnerability repository GitHub - SethPyle376/hiraeth: Local AWS emulator focused on fast integration testing, with SQS support, SQLite-backed state, and a debug-friendly web UI. GitHub - macOS26/Agent: Any AI, replaces Claude Code, Cursor, OpenClaw. Over 18 LLM providers (Claude, OpenAI, Gemini, Ollama, Zai, HF, Qwen) wired into a native Mac app that writes code, builds Xcode projects, bumps versions, manages git, automates Safari, use AppleScript, JS or Accessibility, extend Agent! w/ MCP Servers, run tasks from your iPhone via Messages. YouTube now lets you turn off Shorts I Made a Terminal Pager Burgers | マクドナルド公式 Commands — HackerNews CLI documentation ChatGPT for Excel PiCore - Raspberry Pi Port of Tiny Core Linux Live Nation illegally monopolized ticketing market, jury finds Google Broke Its Promise to Me. Now ICE Has My Data. Founding Engineer at Adaptional | Y Combinator CRISPR takes important step toward silencing Down syndrome’s extra chromosome GitHub - saffron-health/libretto: The AI toolkit for building reliable browser automations US v. Heppner (S.D.N.Y. 2026) no attorney-client privilege for AI chats [pdf] Retrofitting JIT Compilers into C Interpreters IPv6 – Google The Accursèd Alphabetical Clock Cybersecurity Looks Like Proof of Work Now Fragments: April 14 Cal.com Goes Closed Source: Why AI Security Is Forcing Our Decision | Cal.com - Scheduling Software for Online Bookings Laravel raised money and now injects ads directly into your agent When moving fast, talking is the first thing to break Too much Discussion of the XOR swap trick – Heather Cafe Introduction to Spherical Harmonics for Graphics Programmers The Grand Line
Golden Testing a CAD Library
2026-05-12 · via Hacker News

As I’ve written about before, I’m the author/maintainer of a Haskell library for programmable CAD, called Waterfall-CAD.

Ever since I released this in 2023, it’s bothered me that I don’t really have tests for it.

Testing a CAD library like Waterfall-CAD is difficult, because the outputs of a Waterfall-CAD program are generally 3D models, and are difficult things to write good test assertions about.

In 2025, I added SVG support to Waterfall-CAD, converting the images in the README.md from screenshots of a mesh viewer, to vector diagrams generated directly within Haskell code.

While testing solid models seems inherently tricky, there’s an established field of “Visual Regression Testing” tools, so having SVG output seemed vastly more testable than 3d model output1.

Visual Regression Testing

“Visual Regression Testing” is mostly used when testing UI code.

“Visual Regression Tools” work by storing a snapshot of an image generated by an application 2, generating a visual diff of the current behaviour compared to that snapshot, and failing the test if the current behaviour looks significantly different. They also usually provide a mechanism to “accept” the current behaviour; overwriting the snapshots with new outputs, as well as a mechanism to visualize the difference between the expected and actual behaviour, highlighting the parts of the snapshot that have changed.

A Note on Terminology

“Golden Testing” 3 is the name of a testing technique where the expected output of a program is stored in a file, and the program is tested by comparing the current output to that file. “Golden Testing” tools also generally provide a mechanism to “accept” the current program behaviour, and “overwrite” the files with the current behaviour.

It seems useful to me to treat “Visual Regression Testing” as a special case of “Golden Testing” where the test files are images, and the “diff” is a visual diff, rather than a precise comparison of the binary structure of the files.

Going into this project, I thought that the term for the kind of test that I wanted to write was “Snapshot Testing”.

I’m now pretty sure that’s incorrect, “Snapshot Testing” seems to be used to describe exactly the same technique as “Golden Testing” (although the different terms are common in different programming language communities).

I’m currently using the term “Visual Regression Testing” for what I’m doing; I think this is synonymous with the (also commonly used) term “Visual Snapshot Testing”.

I still think it’s useful to think of this as a special case of “Golden Testing” or “Snapshot Testing”. Indeed, I’m using the Haskell Golden Testing library tasty-golden4 to implement these tests.

What I’m Doing Specifically

I’ve added a series of tests based on the diagrams that had already been generated for the README.

The images are stored as SVG, with some custom css so they render differently according to whether the README’s being viewed in dark mode or not.

I like having the images be dual purpose, because it’s one less thing to keep in sync.

The Rasterific-SVG library is used to convert both the SVG in the repo, and the one generated by the code under test, into a JuicyPixels image.

Once we’ve got two images, the code asserts that they both have the same size. If they do, it compares each pixel in the images, and counts the number of pixels that differ by a Manhattan distance of more than a certain amount. If this count of mismatched pixels is higher than some tolerance value, the test fails.

On test failure, a “diff image” is written, which highlights the pixels that differed.

You can see the code doing all this in the DiagramGoldenTests.hs file in the GitHub repo.

I made this image by deliberately failing the tests by changing the colour used for the hidden lines.

Is There an Open-Source Library In This?

I think there might be.

But at the moment, I’m a small distance away from having written it.

A proper library would have to support more of JuicyPixels’ Pixel formats.

It would need to make the diff visualization more customizable (you don’t want to show differences in red if the image already contains a whole lot of red).

It would also need to support loading images directly from disk, instead of the “via-svg” juggling that I’m doing.

At the moment, I’m leaning towards not doing any of that, but I’m torn, and if one person says “yeah, I’d use that”, there’s a good chance I can be persuaded.


  1. Like “knowing you should eat vegetables”, aspiring to write tests is much easier than actually writing them, hence the nearly a year gap between adding SVG support and testing it.↩︎

  2. Usually a screenshot of an application in the case of testing a User Interface; although not in this specific case.↩︎

  3. or “Characterization Testing” , or “Golden Record Testing”, or “Golden Master Testing”↩︎

  4. tasty-silver is a relatively commonly used fork of tasty-golden; I thought this was also worth mentioning.↩︎