diff --git a/tests/env_command_test.go b/tests/env_command_test.go index 59c2d933..85da4ebb 100644 --- a/tests/env_command_test.go +++ b/tests/env_command_test.go @@ -16,36 +16,58 @@ type EnvData struct { } func runL2CommandAndParseJSON(t *testing.T, cmdArgs ...string) { +// Store the original working directory +originalPath, err := os.Getwd() +if err != nil { + fmt.Println("Error getting the current working directory:", err) + return +} - // Store the current working directory - originalPath, err := os.Getwd() - if err != nil { - fmt.Println("Error getting the current working directory:", err) - return - } - listFilesInDir(originalPath) - - // Change the current working directory to lama2Path - l2BinPath := "/home/runner/work/Lama2/Lama2" - err = os.Chdir(l2BinPath) - if err != nil { - fmt.Println("Error changing the current working directory:", err) - return - } - - listFilesInDir(l2BinPath) - - cmd := exec.Command("./../build/l2", cmdArgs...) // Use "./l2" as the executable name - - var stdout bytes.Buffer - cmd.Stdout = &stdout - - // Execute the command - err = cmd.Run() // Uncomment this line to execute the "l2" command +// Change the current working directory to lama2Path +l2BinPath := "/home/runner/work/Lama2/Lama2/build" +err = os.Chdir(l2BinPath) +if err != nil { + fmt.Println("Error changing the current working directory:", err) + return +} + +// Print the current working directory to verify +wd, err := os.Getwd() +if err != nil { + fmt.Println("Error getting the current working directory:", err) + return +} +fmt.Println("Current working directory after changing:", wd) + +// Now let's check if the l2 binary is present in the current working directory +fileInfo, err := os.Stat("./l2") +if err != nil { + fmt.Println("Error checking l2 binary:", err) + return +} +fmt.Println("Is l2 binary present:", fileInfo.Mode().IsRegular()) + +// Change back to the original working directory after debugging +defer func() { + err := os.Chdir(originalPath) if err != nil { - // Handle the error if needed - fmt.Printf("Error running l2 command: %v\n", err) + fmt.Println("Error changing back to the original working directory:", err) } +}() + +// Your existing code to run the l2 command and parse JSON +cmd := exec.Command("./l2", cmdArgs...) // Use "./l2" as the executable name + +var stdout bytes.Buffer +cmd.Stdout = &stdout + +// Execute the command +err = cmd.Run() // Uncomment this line to execute the "l2" command +if err != nil { + // Handle the error if needed + fmt.Printf("Error running l2 command: %v\n", err) + return +} // Retrieve the captured stdout stdoutOutput := stdout.String()