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

WIP:Serialization go #101

Open
wants to merge 1 commit into
base: serialization
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
6 changes: 4 additions & 2 deletions ci-go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ ln -s ../../../../../../runtime/go compiled/go/src/github.com/kaitai-io/kaitai_s

ABS_TEST_OUT_DIR="$(pwd)/$TEST_OUT_DIR"
ABS_TEST_RUN_LOG="$ABS_TEST_OUT_DIR/go/test_run.stdout"
rm -rf "$TEST_OUT_DIR/go"
mkdir -p "$TEST_OUT_DIR/go"
rm -rf "$TEST_OUT_DIR/go" "$TEST_OUT_DIR/go-write"
mkdir -p "$TEST_OUT_DIR/go" "$TEST_OUT_DIR/go-write"

ABS_SPEC_DIR="$(pwd)/spec/go"
ABS_COMPILED_DIR="$(pwd)/compiled/go"
Expand Down Expand Up @@ -95,4 +95,6 @@ COUNT_PASS=$(grep -c '^--- PASS' "$ABS_TEST_RUN_LOG")
echo "Totals: $COUNT_TOTAL ran, $COUNT_PASS passed, $COUNT_FAIL failed"

./kst-adoption-report go
./kst-adoption-report go-write
aggregate/convert_to_json go "$TEST_OUT_DIR/go" "$TEST_OUT_DIR/go/ci.json"
aggregate/convert_to_json go-write "$TEST_OUT_DIR/go-write" "$TEST_OUT_DIR/go-write/ci.json"
6 changes: 4 additions & 2 deletions kst-adoption-report
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def glob_spec_files(lang)
when 'csharp'
Dir.glob('spec/csharp/kaitai_struct_csharp_tests/tests/Spec*.cs')
when 'go'
Dir.glob('spec/go/*_test.go')
Dir.glob('spec/go/spec/*_test.go')
when 'go-write'
Dir.glob('spec/go/specwrite/*_test.go')
when 'java'
Dir.glob('spec/java/src/**/spec/Test*.java')
when 'java-write'
Expand Down Expand Up @@ -51,7 +53,7 @@ def spec_file_to_test_name(lang, fn)
when 'csharp'
raise "Unable to extract test name from #{fn.inspect}" unless fn =~ /^Spec(.*?)\.cs$/
$1
when 'go'
when 'go', 'go-write'
raise "Unable to extract test name from #{fn.inspect}" unless fn =~ /^(.*?)_test\.go$/
underscore_to_ucamelcase($1)
when 'java', 'java-write'
Expand Down
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ class TestTranslator(options: CLIOptions) {
case "cpp_stl_98" => new CppStlSG(testSpec, provider, CppRuntimeConfig().copyAsCpp98())
case "cpp_stl_11" => new CppStlSG(testSpec, provider, CppRuntimeConfig().copyAsCpp11())
case "csharp" => new CSharpSG(testSpec, provider)
case "go" => new GoSG(testSpec, provider)
case "go" => if (options.readWrite) {
new GoWriteSG(testSpec, provider)
} else {
new GoSG(testSpec, provider)
}
case "java" => if (options.readWrite) {
new JavaWriteSG(testSpec, provider)
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.kaitai.struct.testtranslator.specgenerators

import _root_.io.kaitai.struct.datatype.{DataType, KSError}
import _root_.io.kaitai.struct.datatype.{DataType, KSError, EndOfStreamError}
import _root_.io.kaitai.struct.exprlang.Ast
import _root_.io.kaitai.struct.languages.GoCompiler
import _root_.io.kaitai.struct.testtranslator.{Main, TestAssert, TestEquals, TestSpec}
Expand Down Expand Up @@ -34,7 +34,7 @@ class GoSG(spec: TestSpec, provider: ClassTypeProvider) extends BaseGenerator(sp
val className = GoCompiler.types2class(List(spec.id))
val translator = new GoTranslator(new GoOutputWriter(out), provider, importList)

override def fileName(name: String): String = s"${name}_test.go"
override def fileName(name: String): String = s"spec/${name}_test.go"

importList.add("\"runtime/debug\"")
importList.add("\"os\"")
Expand Down