Skip to content

Commit 2d80dad

Browse files
committed
restructured test codes to stop my IDE from freaking out from java files name being named the same thing as the name of the public class (sigh)
1 parent 942949f commit 2d80dad

49 files changed

Lines changed: 14 additions & 3 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

integration_test.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ func testPrivilegedSyscallDeniedForLanguage(t *testing.T, h integrationHarness,
666666

667667
func mustLoadSampleCode(t *testing.T, fileName string, replacements map[string]string) string {
668668
t.Helper()
669-
path := filepath.Join(sampleCodeDir, fileName)
669+
path := resolveSampleCodePath(fileName)
670670
content, err := os.ReadFile(path)
671671
if err != nil {
672672
t.Fatalf("failed to read sample code %s: %v", path, err)
@@ -679,6 +679,18 @@ func mustLoadSampleCode(t *testing.T, fileName string, replacements map[string]s
679679
return code
680680
}
681681

682+
func resolveSampleCodePath(fileName string) string {
683+
ext := filepath.Ext(fileName)
684+
stem := strings.TrimSuffix(fileName, ext)
685+
686+
entryName := "main" + ext
687+
if ext == ".java" {
688+
entryName = "Main.java"
689+
}
690+
691+
return filepath.Join(sampleCodeDir, stem, entryName)
692+
}
693+
682694
func buildCRequest(code string, timeoutSec, maxMemoryKB uint) simpleExecuteRequest {
683695
return buildLanguageRequest("c", code, timeoutSec, maxMemoryKB)
684696
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

sample_code_for_tests/file_privacy_write_read.java renamed to sample_code_for_tests/file_privacy_write_read/Main.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import java.io.IOException;
21
import java.nio.charset.StandardCharsets;
32
import java.nio.file.Files;
43
import java.nio.file.Path;

0 commit comments

Comments
 (0)