From df6f9c7cd565029fda13a4ecab64b2cd1f54f11d Mon Sep 17 00:00:00 2001 From: Ryan Date: Thu, 23 May 2024 18:53:42 +0000 Subject: [PATCH] fix: paths for the elf files, are hardcoded, add temp workaround --- internal/elf_executable/main.go | 16 +++++++++++++++- internal/test_helpers/fixtures/base/pass | 1 - internal/test_helpers/fixtures/navigation/pass | 1 - 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/internal/elf_executable/main.go b/internal/elf_executable/main.go index 967c450a..37f25e92 100644 --- a/internal/elf_executable/main.go +++ b/internal/elf_executable/main.go @@ -24,7 +24,21 @@ var inputFiles = []string{ func CreateELFexecutable(randomString string, outputFile string) error { var concatenatedData []byte + // HACK: This is a workaround to make the paths work for CI + var useParentDirFlag bool + + file := inputFiles[0] + stat, err := os.Stat(file) + if err != nil || stat == nil { + useParentDirFlag = true + } + for _, inputFile := range inputFiles { + // FIXME + if useParentDirFlag { + inputFile = strings.Join(strings.Split(inputFile, "/")[2:], "/") + } + binaryData, err := getBinaryDataFromHexFile(inputFile, randomString) if err != nil { return fmt.Errorf("CodeCrafters internal error. Unable to read from ELF constituent files: %v", err) @@ -32,7 +46,7 @@ func CreateELFexecutable(randomString string, outputFile string) error { concatenatedData = append(concatenatedData, binaryData...) } - err := os.WriteFile(outputFile, concatenatedData, 0755) + err = os.WriteFile(outputFile, concatenatedData, 0755) if err != nil { return fmt.Errorf("CodeCrafters internal error. Failed to write output ELF file: %v", err) } diff --git a/internal/test_helpers/fixtures/base/pass b/internal/test_helpers/fixtures/base/pass index 3c8cf3a1..65b5d89d 100644 --- a/internal/test_helpers/fixtures/base/pass +++ b/internal/test_helpers/fixtures/base/pass @@ -2,7 +2,6 @@ Debug = true [stage-8] Running tests for Stage #8: ip1 [stage-8] Running ./spawn_shell.sh -/workspaces/shell-tester/internal [your-program] $ [stage-8] > ./my_exe [your-program] 384215599859 diff --git a/internal/test_helpers/fixtures/navigation/pass b/internal/test_helpers/fixtures/navigation/pass index 87da2be1..d1a9fe6a 100644 --- a/internal/test_helpers/fixtures/navigation/pass +++ b/internal/test_helpers/fixtures/navigation/pass @@ -72,7 +72,6 @@ Debug = true [stage-8] Running tests for Stage #8: ip1 [stage-8] Running ./spawn_shell.sh -/workspaces/shell-tester/internal [your-program] $ [stage-8] > ./my_exe [your-program] 384215599859