@@ -202,7 +202,7 @@ func runAnalyze(cmd *cobra.Command, args []string) error {
202202 return nil
203203}
204204
205- func runGenerate ( cmd * cobra. Command , args [] string ) error {
205+ func generateTests ( ) error {
206206 fmt .Println ("================================================================================" )
207207 fmt .Println ("Generating Unit Tests" )
208208 fmt .Println ("================================================================================" )
@@ -263,6 +263,10 @@ func runGenerate(cmd *cobra.Command, args []string) error {
263263 return nil
264264}
265265
266+ func runGenerate (cmd * cobra.Command , args []string ) error {
267+ return generateTests ()
268+ }
269+
266270func runValidate (cmd * cobra.Command , args []string ) error {
267271 fmt .Println ("================================================================================" )
268272 fmt .Println ("Validating Generated Tests" )
@@ -301,38 +305,6 @@ func runValidate(cmd *cobra.Command, args []string) error {
301305 fmt .Printf ("Validation Attempt %d/%d\n " , attempt , maxRetries )
302306 fmt .Printf ("================================================================================\n " )
303307
304- // Generate new tests for each attempt (except the first one which uses existing)
305- if attempt > 1 {
306- fmt .Println ("\n Regenerating tests with different seed..." )
307-
308- // Read file content
309- content , err := os .ReadFile (backupPath )
310- if err != nil {
311- lastErr = fmt .Errorf ("failed to read original file: %w" , err )
312- continue
313- }
314-
315- // Generate new tests
316- generatedTests , err := callGitHubModelsAPI (string (content ), originalFilePath , analysis .Stats )
317- if err != nil {
318- lastErr = fmt .Errorf ("failed to regenerate tests: %w" , err )
319- continue
320- }
321-
322- // Integrate tests into the file
323- updatedContent := integrateTests (string (content ), generatedTests )
324-
325- // Save updated file
326- testFilePath := filepath .Join (outputDir , "updated_file.rs" )
327- if err := os .WriteFile (testFilePath , []byte (updatedContent ), 0644 ); err != nil {
328- lastErr = fmt .Errorf ("failed to write updated file: %w" , err )
329- continue
330- }
331-
332- // Update metadata
333- metadata ["generated_tests_path" ] = testFilePath
334- }
335-
336308 testFilePath := metadata ["generated_tests_path" ].(string )
337309
338310 // Copy generated file to original location
@@ -343,23 +315,17 @@ func runValidate(cmd *cobra.Command, args []string) error {
343315
344316 // Run cargo check
345317 fmt .Println ("\n Running cargo check..." )
346- if err := runCommand ("cargo" , "check" , "--workspace" ); err != nil {
347- fmt .Println ("❌ Compilation failed!" )
348- lastErr = err
349- copyFile (backupPath , originalFilePath ) // Restore backup
350- continue
351- }
352- fmt .Println ("✅ Compilation successful!" )
353-
354- // Run tests
355- fmt .Println ("\n Running tests..." )
356- if err := runCommand ("cargo" , "test" , "--workspace" , "--" , "--skip" , "integration" , "--nocapture" ); err != nil {
357- fmt .Println ("❌ Tests failed!" )
318+ if err := runCommand ("make" , "ut" ); err != nil {
319+ fmt .Println ("❌ UT failed!" )
358320 lastErr = err
359321 copyFile (backupPath , originalFilePath ) // Restore backup
322+ // Regenerate tests
323+ if err := generateTests (); err != nil {
324+ return fmt .Errorf ("failed to regenerate tests: %w" , err )
325+ }
360326 continue
361327 }
362- fmt .Println ("✅ All tests passed !" )
328+ fmt .Println ("✅ UT successful !" )
363329
364330 success = true
365331 break
0 commit comments