Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add synced PCL files to program gen tests #865

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions pkg/codegen/java/gen_program_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package java

import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"testing"
Expand All @@ -16,15 +16,46 @@ type PclTestFile struct {
}

var testdataPath = filepath.Join("..", "testing", "test", "testdata")
var transpiledExamplesDir = "transpiled_examples"

var skipGenerationTests = []string{
"azure-container-apps",
"getting-started",
"pulumi-variable",
}

func skipGeneration(test string) bool {
for _, t := range skipGenerationTests {
if t == test {
return true
}
}
return false
}

func TestGenerateJavaProgram(t *testing.T) {
t.Parallel()

files, err := ioutil.ReadDir(testdataPath)
files, err := os.ReadDir(testdataPath)
assert.NoError(t, err)
tests := make([]test.ProgramTest, 0, len(files))
for _, f := range files {
name := f.Name()
if f.IsDir() && name == transpiledExamplesDir {
syncDir := filepath.Join(testdataPath, transpiledExamplesDir)
files, err := os.ReadDir(syncDir)
assert.NoError(t, err)
for _, f := range files {
name := strings.TrimSuffix(f.Name(), "-pp")
if skipGeneration(name) {
continue
}
tests = append(tests, test.ProgramTest{
Directory: filepath.Join(transpiledExamplesDir, name),
})
}
continue
}
if !strings.HasSuffix(name, "-pp") {
continue
}
Expand Down
Loading