File tree Expand file tree Collapse file tree 5 files changed +62
-3
lines changed
Expand file tree Collapse file tree 5 files changed +62
-3
lines changed Original file line number Diff line number Diff line change 11exports_files ([
2- "version.bzl" ,
32 "LICENSE" ,
3+ "MODULE.bazel" ,
4+ "version.bzl" ,
45])
Original file line number Diff line number Diff line change 22
33module (
44 name = "rules_typst" ,
5- version = "0.1 .0" ,
5+ version = "0.2 .0" ,
66)
77
88bazel_dep (name = "rules_rust" , version = "0.68.1" )
Original file line number Diff line number Diff line change 1+ load ("@rules_rust//rust:defs.bzl" , "rust_test" )
2+ load ("//:version.bzl" , "VERSION" )
3+
4+ rust_test (
5+ name = "bzl_version_test" ,
6+ srcs = ["bzl_version_test.rs" ],
7+ data = [
8+ "//:MODULE.bazel" ,
9+ ],
10+ edition = "2021" ,
11+ env = {
12+ "MODULE_BAZEL" : "$(rlocationpath //:MODULE.bazel)" ,
13+ "VERSION" : VERSION ,
14+ },
15+ deps = [
16+ "@rules_rust//rust/runfiles" ,
17+ ],
18+ )
Original file line number Diff line number Diff line change 1+ //! A test to ensure the rules_rust bzlmod versions match the standard versions.
2+
3+ use runfiles:: Runfiles ;
4+
5+ fn parse_module_bazel_version ( text : & str ) -> String {
6+ let mut found_module = false ;
7+ for line in text. split ( '\n' ) {
8+ if found_module {
9+ assert ! ( !line. ends_with( ')' ) , "Failed to parse version" ) ;
10+ if let Some ( ( param, value) ) = line. rsplit_once ( " = " ) {
11+ if param. trim ( ) == "version" {
12+ return value. trim ( ) . trim_matches ( ',' ) . trim_matches ( '"' ) . to_owned ( ) ;
13+ }
14+ }
15+ } else if line. starts_with ( "module(" ) {
16+ found_module = true ;
17+ continue ;
18+ }
19+ }
20+ panic ! ( "Failed to find MODULE.bazel version" ) ;
21+ }
22+
23+ /// If this test fails it means `//:version.bzl` and `//:MODULE.bazel` need to
24+ /// be synced up. `//:version.bzl` should contain the source of truth.
25+ #[ test]
26+ fn module_bzl_has_correct_version ( ) {
27+ let version = std:: env:: var ( "VERSION" ) . unwrap ( ) ;
28+ let module_bazel_text = {
29+ let r = Runfiles :: create ( ) . unwrap ( ) ;
30+ let path = runfiles:: rlocation!( r, std:: env:: var( "MODULE_BAZEL" ) . unwrap( ) ) . unwrap ( ) ;
31+ std:: fs:: read_to_string ( path) . unwrap ( )
32+ } ;
33+
34+ let module_bazel_version = parse_module_bazel_version ( & module_bazel_text) ;
35+
36+ assert_eq ! (
37+ version, module_bazel_version,
38+ "@rules_typst//:version.bzl and //:MODULE.bazel versions are out of sync"
39+ ) ;
40+ }
Original file line number Diff line number Diff line change 11""""rules_typst version"""
22
3- VERSION = "0.1 .0"
3+ VERSION = "0.2 .0"
You can’t perform that action at this time.
0 commit comments