Skip to content

Commit 64ecfd3

Browse files
committed
feat: gts builder file paths
Signed-off-by: devjow <me@devjow.com>
1 parent 4cf619b commit 64ecfd3

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

gts-cli/src/gen_instances/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ fn check_duplicate_output_paths(
121121

122122
for inst in instances {
123123
let composed = format!("{}{}", inst.attrs.schema_id, inst.attrs.instance_segment);
124-
let file_rel = format!("{}/{}.instance.json", inst.attrs.dir_path, composed);
124+
let file_rel =
125+
std::path::Path::new(&inst.attrs.dir_path).join(format!("{composed}.instance.json"));
125126
let raw_path = if let Some(od) = output {
126127
Path::new(od).join(&file_rel)
127128
} else {

gts-cli/src/gen_instances/writer.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ pub fn generate_single_instance(
2424
sandbox_root: &Path,
2525
) -> Result<String> {
2626
let composed = format!("{}{}", inst.attrs.schema_id, inst.attrs.instance_segment);
27-
let file_rel = format!("{}/{}.instance.json", inst.attrs.dir_path, composed);
27+
let file_rel =
28+
std::path::Path::new(&inst.attrs.dir_path).join(format!("{composed}.instance.json"));
2829

2930
let raw_output_path = if let Some(od) = output {
3031
Path::new(od).join(&file_rel)

gts-cli/tests/gen_instances_tests.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,14 @@ fn gts_ignore_directive_skips_file() {
372372

373373
#[test]
374374
fn missing_source_path_errors() {
375-
let err = run("/nonexistent/path/absolutely/not/here", None, &[]).unwrap_err();
375+
// Use a path guaranteed not to exist on any platform by constructing it
376+
// inside a TempDir that is immediately dropped (and thus deleted).
377+
let nonexistent = {
378+
let tmp = TempDir::new().unwrap();
379+
tmp.path().join("no_such_subdir_xyz")
380+
// tmp is dropped here — the parent dir is deleted
381+
};
382+
let err = run(nonexistent.to_str().unwrap(), None, &[]).unwrap_err();
376383
assert!(err.to_string().contains("does not exist"), "Got: {err}");
377384
}
378385

0 commit comments

Comments
 (0)