Skip to content

refactor: move various file generation from tests to a separate crate #774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

magistau
Copy link
Contributor

No description provided.

@magistau magistau marked this pull request as draft July 14, 2025 09:04
@magistau magistau force-pushed the helper branch 2 times, most recently from fb3e54a to 0600a16 Compare July 14, 2025 09:20
@magistau magistau marked this pull request as ready for review July 14, 2025 09:21
@kaikalii
Copy link
Member

Can you briefly explain this change?

@magistau
Copy link
Contributor Author

Pretty much what it says in the commit message. Instead of using tests for generating files like site/primitives.json, a new executable crate named uiua-helper is used.

@kaikalii
Copy link
Member

What is the motivation?

@magistau
Copy link
Contributor Author

Tests are intended for, well, testing, not for generating arbitrary files inside the repository. Especially since these tests are all in different places, it is not clear how and which files are generated. For example, creation of files inside ./site/text/ when testing the main crate which doesn't involve the website is pretty surprising. And likewise, it is surprising that to build some part of Uiua you need to run tests of a certain crate first. Everything generated by build/test process should be in either designated directories (like ./target/ or ~/.cargo/) or in temporary directories somewhere in /tmp/ which the user doesn't need to care about.

@magistau
Copy link
Contributor Author

Also, files which can be fully generated from existing files shouldn't be tracked by Git, since they bear zero entropy and can easily go out of sync. site/primitives.json, for example, is fully determined by uiua implementation and so it should be considered a build artifact untracked by Git and only generated when building the website. Cargo.lock, however, is not fully determined by Cargo.toml files, as different lockfiles can correspond to the same manifest, so Cargo.lock should be tracked.

@kaikalii
Copy link
Member

site/primitives.json needs to be available in the git repo to be useful externally.

@magistau
Copy link
Contributor Author

By the way, site/blog/feed.rss is most likely a generated file, but I couldn't find where it is generated.

@kaikalii
Copy link
Member

I like having generation in tests so I don't forget to run it.
Does this create any specific problems?

@magistau
Copy link
Contributor Author

site/primitives.json needs to be available in the git repo to be useful externally.

Isn't it hosted by the website as https://www.uiua.org/primitives.json? And it would be available on the site branch anyway.

@magistau
Copy link
Contributor Author

Does this create any specific problems?

Other than being unintuitive, this caused some troubles with Nix packaging (due to Nix making a lot of files read-only), but that was circumvented by disabling those "tests".

@magistau
Copy link
Contributor Author

I like having generation in tests so I don't forget to run it.

Why would you need to "not forget to run it"? It can be done automatically by CI, for example.

@kaikalii
Copy link
Member

I think they folder should probably be called generate rather than helper.

@magistau
Copy link
Contributor Author

I think they folder should probably be called generate rather than helper.

Renamed to generator

@magistau
Copy link
Contributor Author

Also, files which can be fully generated from existing files shouldn't be tracked by Git, since they bear zero entropy and can easily go out of sync. site/primitives.json, for example, is fully determined by uiua implementation and so it should be considered a build artifact untracked by Git and only generated when building the website. Cargo.lock, however, is not fully determined by Cargo.toml files, as different lockfiles can correspond to the same manifest, so Cargo.lock should be tracked.

In fact, site/primitives.json is actually out of sync with the docs. See backward docs and the relevant entry in site/primitives.json.

@@ -42,7 +42,8 @@ thread_local! {
[
("example.ua", EXAMPLE_UA),
("example.txt", EXAMPLE_TXT),
("primitives.json", include_str!("../../../site/primitives.json"))
#[cfg(feature="default")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have feature gates in the pad?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make site and uiua-editor usable as libraries without pulling unnecessary stuff. site::markdown::markdown_html is hard to decouple from the site crate, so generator needs to depend on site. For that, a more or less minimal version of site should be available, and that depends on uiua-editor. IIRC I also faced site and uiua-editor depending on the generated files, which doesn't seem adequate for a task as simple as converting markdown to HTML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants