Repository: Konstantin8105/c4go
Pull request #423 (2019-04-24 05:58:27)

More examples

codecov[bot]: # [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/423?src=pr&el=h1) Report
> Merging [#423](https://codecov.io/gh/Konstantin8105/c4go/pull/423?src=pr&el=desc) into [master](https://codecov.io/gh/Konstantin8105/c4go/commit/beaf52d98482750dfb1c6b6810b0e9ce2b3106e9?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `n/a`.

[![Impacted file tree graph](https://codecov.io/gh/Konstantin8105/c4go/pull/423/graphs/tree.svg?width=650&token=esH2rHXlZ2&height=150&src=pr)](https://codecov.io/gh/Konstantin8105/c4go/pull/423?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master     #423   +/-   ##
=======================================
  Coverage   85.07%   85.07%           
=======================================
  Files         191      191           
  Lines       11637    11637           
=======================================
  Hits         9900     9900           
  Misses       1259     1259           
  Partials      478      478
```



------

[Continue to review full report at Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/423?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/Konstantin8105/c4go/pull/423?src=pr&el=footer). Last update [beaf52d...8c3587a](https://codecov.io/gh/Konstantin8105/c4go/pull/423?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/scripts/brainfuck.sh b/scripts/brainfuck.sh
new file mode 100755
index 0000000..ab3920d
--- /dev/null
+++ b/scripts/brainfuck.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+set -e
+
+go build
+
+mkdir -p ./testdata/
+
+# prepare variables
+	export C4GO_DIR=$GOPATH/src/github.com/Konstantin8105/c4go
+	export C4GO=$C4GO_DIR/c4go
+	export GIT_SOURCE="https://github.com/kgabis/brainfuck-c.git"
+	export NAME="brainfuck"
+	export TEMP_FOLDER="./testdata/$NAME"
+	export GO_FILE="$TEMP_FOLDER/$NAME.go"
+	export GO_APP="$TEMP_FOLDER/$NAME.app"
+
+# prepare C code
+    if [ ! -d $TEMP_FOLDER ]; then
+		mkdir -p $TEMP_FOLDER
+		git clone $GIT_SOURCE $TEMP_FOLDER
+	fi
+
+# remove go files from last transpilation
+	echo "***** remove go files"
+	rm -f $TEMP_FOLDER/*.go
+	rm -f $TEMP_FOLDER/*.app
+
+# transpilation of all projects
+	echo "Transpile to $GO_FILE"
+	$C4GO transpile                         \
+		-clang-flag="-DTROFFFDIR=\"MMM\""	\
+		-clang-flag="-DTROFFMDIR=\"WWW\""	\
+		-o="$GO_FILE"                       \
+		$TEMP_FOLDER/*.c
+
+# show warnings comments in Go source
+	echo "Calculate warnings in file: $GO_FILE"
+	WARNINGS=`cat $GO_FILE | grep "^// Warning" | sort | uniq | wc -l`
+	echo "		After transpiling : $WARNINGS warnings."
+
+# show other warnings
+	# show amount error from `go build`:
+		echo "Build to $GO_APP file"
+		WARNINGS_GO=`go build -o $GO_APP -gcflags="-e" $GO_FILE 2>&1 | wc -l`
+		echo "		Go build : $WARNINGS_GO warnings"
+	# amount unsafe
+		UNSAFE=`cat $GO_FILE | grep "unsafe\." | wc -l`
+		echo "		Unsafe   : $UNSAFE"
+
+
+# Arguments menu
+echo "    -s for show detail of Go build errors"
+if [ "$1" == "-s" ]; then
+	# show go build warnings	
+		# c4go warnings
+			cat $GO_FILE | grep "^// Warning" | sort | uniq
+		# show amount error from `go build`:
+			go build -o $GO_APP -gcflags="-e" $GO_FILE 2>&1
+fi
+
+
diff --git a/scripts/progress.sh b/scripts/progress.sh
new file mode 100755
index 0000000..4e690dd
--- /dev/null
+++ b/scripts/progress.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+set -e
+
+go build
+
+mkdir -p ./testdata/
+
+# prepare variables
+	export C4GO_DIR=$GOPATH/src/github.com/Konstantin8105/c4go
+	export C4GO=$C4GO_DIR/c4go
+	export GIT_SOURCE="https://github.com/jwerle/progress.c.git"
+	export NAME="progress"
+	export TEMP_FOLDER="./testdata/$NAME"
+	export GO_FILE="$TEMP_FOLDER/$NAME.go"
+	export GO_APP="$TEMP_FOLDER/$NAME.app"
+
+# prepare C code
+    if [ ! -d $TEMP_FOLDER ]; then
+		mkdir -p $TEMP_FOLDER
+		git clone $GIT_SOURCE $TEMP_FOLDER
+		sed -i.bak -e '2d'                                        $TEMP_FOLDER/test.c
+		sed -i.bak -e '2i  #include "progress.h"' $TEMP_FOLDER/test.c
+	fi
+
+# remove go files from last transpilation
+	echo "***** remove go files"
+	rm -f $TEMP_FOLDER/*.go
+	rm -f $TEMP_FOLDER/*.app
+
+# transpilation of all projects
+	echo "Transpile to $GO_FILE"
+	$C4GO transpile                         \
+		-clang-flag="-I.."                	\
+		-o="$GO_FILE"                       \
+		$TEMP_FOLDER/test.c
+
+# show warnings comments in Go source
+	echo "Calculate warnings in file: $GO_FILE"
+	WARNINGS=`cat $GO_FILE | grep "^// Warning" | sort | uniq | wc -l`
+	echo "		After transpiling : $WARNINGS warnings."
+
+# show other warnings
+	# show amount error from `go build`:
+		echo "Build to $GO_APP file"
+		WARNINGS_GO=`go build -o $GO_APP -gcflags="-e" $GO_FILE 2>&1 | wc -l`
+		echo "		Go build : $WARNINGS_GO warnings"
+	# amount unsafe
+		UNSAFE=`cat $GO_FILE | grep "unsafe\." | wc -l`
+		echo "		Unsafe   : $UNSAFE"
+
+
+# Arguments menu
+echo "    -s for show detail of Go build errors"
+if [ "$1" == "-s" ]; then
+	# show go build warnings	
+		# c4go warnings
+			cat $GO_FILE | grep "^// Warning" | sort | uniq
+		# show amount error from `go build`:
+			go build -o $GO_APP -gcflags="-e" $GO_FILE 2>&1
+fi
+
+
+
diff --git a/scripts/scripts.sh b/scripts/scripts.sh
index ed1bfde..fde1ab8 100755
--- a/scripts/scripts.sh
+++ b/scripts/scripts.sh
@@ -9,6 +9,9 @@ export VERIFICATION_FILE="./scripts/scripts.txt"
 
 echo "" > $OUTPUT_FILE
 
+./scripts/brainfuck.sh		2>&1 | grep -E 'warning|unsafe|Unsafe' | tee -a $OUTPUT_FILE
+echo "" >> $OUTPUT_FILE
+
 ./scripts/9wm.sh		2>&1 | grep -E 'warning|unsafe|Unsafe' | tee -a $OUTPUT_FILE
 echo "" >> $OUTPUT_FILE
 
@@ -48,9 +51,15 @@ echo "" >> $OUTPUT_FILE
 ./scripts/triangle.sh		2>&1 | grep -E 'warning|unsafe|Unsafe' | tee -a $OUTPUT_FILE
 echo "" >> $OUTPUT_FILE
 
+./scripts/progress.sh		2>&1 | grep -E 'warning|unsafe|Unsafe' | tee -a $OUTPUT_FILE
+echo "" >> $OUTPUT_FILE
+
 ./scripts/sqlite.sh		2>&1 | grep -E 'warning|unsafe|Unsafe' | tee -a $OUTPUT_FILE
 echo "" >> $OUTPUT_FILE
 
+./scripts/tiny_web_server.sh		2>&1 | grep -E 'warning|unsafe|Unsafe' | tee -a $OUTPUT_FILE
+echo "" >> $OUTPUT_FILE
+
 ./scripts/vorbis.sh		2>&1 | grep -E 'warning|unsafe|Unsafe' | tee -a $OUTPUT_FILE
 echo "" >> $OUTPUT_FILE
 
diff --git a/scripts/scripts.txt b/scripts/scripts.txt
index 45db9fa..1fea6b8 100644
--- a/scripts/scripts.txt
+++ b/scripts/scripts.txt
@@ -1,4 +1,9 @@
 
+Calculate warnings in file: ./testdata/brainfuck/brainfuck.go
+		After transpiling : 0 warnings.
+		Go build : 0 warnings
+		Unsafe   : 0
+
 Calculate warnings : ./testdata/9wm
 		After transpiling : 5 warnings.
 		Go build : 4 warnings
@@ -59,11 +64,21 @@ Calculate warnings in file: ./testdata/triangle/triangle.go
 		Go build : 585 warnings
 		Unsafe   : 1416
 
+Calculate warnings in file: ./testdata/progress/progress.go
+		After transpiling : 0 warnings.
+		Go build : 2 warnings
+		Unsafe   : 0
+
 Calculate warnings in file: ./testdata/SQLITE/sqlite.go
 		After transpiling : 1 warnings.
 		Go build : 1 warnings
 		Unsafe   : 2405
 
+Calculate warnings in file: ./testdata/tiny-web-server/tiny-web-server.go
+		After transpiling : 0 warnings.
+		Go build : 2 warnings
+		Unsafe   : 148
+
 Calculate warnings in file: testdata/vorbis/vorbis.go
 		After transpiling : 0 warnings.
 		Go build : 3 warnings
diff --git a/scripts/tiny_web_server.sh b/scripts/tiny_web_server.sh
new file mode 100755
index 0000000..3aedf59
--- /dev/null
+++ b/scripts/tiny_web_server.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+set -e
+
+go build
+
+mkdir -p ./testdata/
+
+# prepare variables
+	export C4GO_DIR=$GOPATH/src/github.com/Konstantin8105/c4go
+	export C4GO=$C4GO_DIR/c4go
+	export GIT_SOURCE="https://github.com/shenfeng/tiny-web-server.git"
+	export NAME="tiny-web-server"
+	export TEMP_FOLDER="./testdata/$NAME"
+	export GO_FILE="$TEMP_FOLDER/$NAME.go"
+	export GO_APP="$TEMP_FOLDER/$NAME.app"
+
+# prepare C code
+    if [ ! -d $TEMP_FOLDER ]; then
+		mkdir -p $TEMP_FOLDER
+		git clone $GIT_SOURCE $TEMP_FOLDER
+	fi
+
+# remove go files from last transpilation
+	echo "***** remove go files"
+	rm -f $TEMP_FOLDER/*.go
+	rm -f $TEMP_FOLDER/*.app
+
+# transpilation of all projects
+	echo "Transpile to $GO_FILE"
+	$C4GO transpile                         \
+		-s                                  \
+		-clang-flag="-DTROFFFDIR=\"MMM\""	\
+		-clang-flag="-DTROFFMDIR=\"WWW\""	\
+		-o="$GO_FILE"                       \
+		$TEMP_FOLDER/*.c
+
+# show warnings comments in Go source
+	echo "Calculate warnings in file: $GO_FILE"
+	WARNINGS=`cat $GO_FILE | grep "^// Warning" | sort | uniq | wc -l`
+	echo "		After transpiling : $WARNINGS warnings."
+
+# show other warnings
+	# show amount error from `go build`:
+		echo "Build to $GO_APP file"
+		WARNINGS_GO=`go build -o $GO_APP -gcflags="-e" $GO_FILE 2>&1 | wc -l`
+		echo "		Go build : $WARNINGS_GO warnings"
+	# amount unsafe
+		UNSAFE=`cat $GO_FILE | grep "unsafe\." | wc -l`
+		echo "		Unsafe   : $UNSAFE"
+
+
+# Arguments menu
+echo "    -s for show detail of Go build errors"
+if [ "$1" == "-s" ]; then
+	# show go build warnings	
+		# c4go warnings
+			cat $GO_FILE | grep "^// Warning" | sort | uniq
+		# show amount error from `go build`:
+			go build -o $GO_APP -gcflags="-e" $GO_FILE 2>&1
+fi
+
+
+


Test patch:
diff --git a/other_test.go b/other_test.go
index dd4e7db..db18629 100644
--- a/other_test.go
+++ b/other_test.go
@@ -78,10 +78,10 @@ func TestBookSources(t *testing.T) {
 		gitSource      string
 		ignoreFileList []string
 	}{
-		{
-			prefix:    "brainfuck",
-			gitSource: "https://github.com/kgabis/brainfuck-c.git",
-		},
+		// {
+		// 	prefix:    "brainfuck",
+		// 	gitSource: "https://github.com/kgabis/brainfuck-c.git",
+		// },
 		// TODO : some travis haven`t enought C libraries
 		// {
 		// 	prefix:    "tiny-web-server",