Skip to content

Commit

Permalink
Add synced PCL files to program gen tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aq17 committed Nov 8, 2022
1 parent edec67d commit 03186b5
Show file tree
Hide file tree
Showing 32 changed files with 2,188,068 additions and 153 deletions.
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

0 comments on commit 03186b5

Please sign in to comment.