@@ -186,11 +186,12 @@ func TestScaffoldSkillWritesLanguageSpecificEntrypoints(t *testing.T) {
186186 files []string
187187 command string
188188 pin string
189+ ignore string
189190 }{
190- {"typescript" , []string {"main.ts" , "package.json" , "skill.json" }, "npm exec -- yskill run ." , `"@operatorstack/yield": "0.1.9"` },
191- {"python" , []string {"main.py" , "requirements.txt" , "skill.json" }, "python -m yieldskill run ." , "yieldskill==0.1.9" },
192- {"go" , []string {"main.go" , "go.mod" , "skill.json" }, "yskill run ." , "github.com/operatorstack/yield v0.1.9" },
193- {"rust" , []string {"src/main.rs" , "Cargo.toml" , "skill.json" }, "yskill run ." , `version = "=0.1.9"` },
191+ {"typescript" , []string {"main.ts" , "package.json" , "skill.json" }, "npm exec -- yskill run ." , `"@operatorstack/yield": "0.1.9"` , "" },
192+ {"python" , []string {"main.py" , "requirements.txt" , "skill.json" }, "python -m yieldskill run ." , "yieldskill==0.1.9" , "" },
193+ {"go" , []string {"main.go" , "go.mod" , "skill.json" }, "yskill run ." , "github.com/operatorstack/yield v0.1.9" , "" },
194+ {"rust" , []string {"src/main.rs" , "Cargo.toml" , "skill.json" , ".gitignore" }, "yskill run ." , `version = "=0.1.9"` , rustSkillGitignore },
194195 }
195196 for _ , tt := range tests {
196197 t .Run (tt .language , func (t * testing.T ) {
@@ -246,13 +247,36 @@ func TestScaffoldSkillWritesLanguageSpecificEntrypoints(t *testing.T) {
246247 if tt .language == "rust" && strings .Contains (manifest , "registry =" ) {
247248 t .Fatalf ("public Rust scaffold contains a private package registry:\n %s" , manifest )
248249 }
250+ ignorePath := filepath .Join (dir , ".gitignore" )
251+ if tt .ignore == "" {
252+ if _ , err := os .Stat (ignorePath ); ! os .IsNotExist (err ) {
253+ t .Fatalf ("%s scaffold created Rust-specific .gitignore: %v" , tt .language , err )
254+ }
255+ } else if got := readTestFile (t , ignorePath ); got != tt .ignore {
256+ t .Fatalf (".gitignore = %q, want %q" , got , tt .ignore )
257+ }
249258 })
250259 }
251260 if tidyCalls != 1 {
252261 t .Fatalf ("go mod tidy calls = %d, want 1" , tidyCalls )
253262 }
254263}
255264
265+ func TestRustScaffoldPreservesExistingGitignore (t * testing.T ) {
266+ dir := filepath .Join (t .TempDir (), "safe-change" )
267+ if err := os .MkdirAll (dir , 0o755 ); err != nil {
268+ t .Fatal (err )
269+ }
270+ const existing = "user-owned-rule/\n "
271+ writeTestFile (t , filepath .Join (dir , ".gitignore" ), existing )
272+ if err := scaffoldSkill (dir , "rust" , "" , "Check a safe change before applying it." ); err != nil {
273+ t .Fatal (err )
274+ }
275+ if got := readTestFile (t , filepath .Join (dir , ".gitignore" )); got != existing {
276+ t .Fatalf ("existing .gitignore changed: %q" , got )
277+ }
278+ }
279+
256280func TestPackageScaffoldsPrintCreatedWorkflowInNextCommands (t * testing.T ) {
257281 previousVersion := version
258282 version = "0.1.28"
@@ -458,6 +482,44 @@ func TestRustScaffoldPinsTheInvokedRuntimeWithoutPrivateRegistryConfig(t *testin
458482 }
459483}
460484
485+ func TestCmdInitRustScaffoldIsDoctorValid (t * testing.T ) {
486+ if _ , err := exec .LookPath ("cargo" ); err != nil {
487+ t .Skip ("cargo is unavailable" )
488+ }
489+ previousVersion := version
490+ previousExecutable := currentExecutable
491+ previousInspect := inspectRuntimeVersion
492+ version = "0.1.37"
493+ t .Cleanup (func () {
494+ version = previousVersion
495+ currentExecutable = previousExecutable
496+ inspectRuntimeVersion = previousInspect
497+ })
498+
499+ root := t .TempDir ()
500+ writeTestFile (t , filepath .Join (root , ".git" ), "gitdir: fixture\n " )
501+ writeTestFile (t , localRuntimePath (root ), "packaged runtime" )
502+ currentExecutable = func () (string , error ) { return localRuntimePath (root ), nil }
503+ inspectRuntimeVersion = func (path string ) (string , error ) {
504+ resolved , err := filepath .EvalSymlinks (localRuntimePath (root ))
505+ if err != nil {
506+ t .Fatal (err )
507+ }
508+ if path != localRuntimePath (root ) && path != resolved {
509+ t .Fatalf ("inspected unexpected runtime %s" , path )
510+ }
511+ return "0.1.37" , nil
512+ }
513+
514+ dir := filepath .Join (root , "skills" , "safe-change" )
515+ if err := cmdInit ([]string {"--language" , "rust" , "--description" , "Check a safe change before applying it." , dir }); err != nil {
516+ t .Fatal (err )
517+ }
518+ if err := cmdDoctor ([]string {dir , "--root" , root }); err != nil {
519+ t .Fatalf ("doctor rejected Rust scaffold: %v" , err )
520+ }
521+ }
522+
461523func TestPythonScaffoldUsesRelocatableInterpreter (t * testing.T ) {
462524 previousVersion := version
463525 version = "0.1.9"
0 commit comments