diff --git a/.gitignore b/.gitignore index aa05b2aa..07f8cef1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,6 @@ *.o -*.swp -*.swo -*.pyc +*.sw* +#*.pyc *.run *.test -*.tar.gz -.* -ocarina.bin .sconsign.dblite -bin/ -PKGBUILD -!PKGBUILD.tmpl diff --git a/design/print.txt b/design/print.txt index bcfb03ee..b32cbb55 100644 --- a/design/print.txt +++ b/design/print.txt @@ -7,10 +7,12 @@ install Printing: (include/print.h> Sometimes text needs to be printed to the screen so users (or debuggers) - know what is going on. + know what is going on. Enabling dprint() when CONFIG_TEST is enabled + means I will only need a single test.good file for output comparing. + API: void print(string fmt, ...) - Print text to the screen + Print text to the screen. void dprint(string fmt, ...) - Print text to the screen when debugging is enabled + Print text to the screen when debugging or testing is enabled. diff --git a/include/print.h b/include/print.h index 5631f341..8d466690 100644 --- a/include/print.h +++ b/include/print.h @@ -16,7 +16,7 @@ inline void print(const char *fmt, ...) va_end(ap); } -#ifdef CONFIG_DEBUG +#if defined(CONFIG_DEBUG) || defined(CONFIG_TEST) inline void dprint(const char *fmt, ...) { va_list ap; @@ -25,7 +25,7 @@ inline void dprint(const char *fmt, ...) vprintf(fmt, ap); va_end(ap); } -#else /* CONFIG_DEBUG */ +#else /* ! (CONFIG_DEBUG || CONFIG_TEST) */ inline void dprint(const char *fmt, ...) {} #endif /* CONFIG_DEBUG */ diff --git a/tests/Sconscript b/tests/Sconscript index b1495a03..8f89680b 100644 --- a/tests/Sconscript +++ b/tests/Sconscript @@ -4,9 +4,6 @@ Import("env", "CONFIG") GOOD = "%s.good" -if CONFIG.DEBUG: - GOOD = "%s-debug.good" - def run_test(target, source, env): res = str(target[0]) diff --git a/tests/basic/.gitignore b/tests/basic/.gitignore new file mode 100644 index 00000000..9c29f432 --- /dev/null +++ b/tests/basic/.gitignore @@ -0,0 +1 @@ +print.good diff --git a/tests/basic/Sconscript b/tests/basic/Sconscript index bc4a6ff9..11915ac2 100644 --- a/tests/basic/Sconscript +++ b/tests/basic/Sconscript @@ -1,4 +1,13 @@ #!/usr/bin/python -Import("Test") +Import("Test", "CONFIG") + +out = open("print.good", 'w') +if CONFIG.DEBUG == True: + out.write("%s-debug\n" % CONFIG.VERSION) + out.write("%s-debug\n" % CONFIG.VERSION) +else: + out.write("%s\n" % CONFIG.VERSION) + out.write("%s\n" % CONFIG.VERSION) +out.close() Test("basic", "print.cpp") diff --git a/tests/basic/print-debug.good b/tests/basic/print-debug.good deleted file mode 100644 index d8943d4c..00000000 --- a/tests/basic/print-debug.good +++ /dev/null @@ -1,2 +0,0 @@ -6.0-debug -6.0-debug diff --git a/tests/basic/print.good b/tests/basic/print.good deleted file mode 100644 index e0ea36fe..00000000 --- a/tests/basic/print.good +++ /dev/null @@ -1 +0,0 @@ -6.0 diff --git a/tests/file/compile-debug.good b/tests/file/compile-debug.good deleted file mode 100644 index c8893370..00000000 --- a/tests/file/compile-debug.good +++ /dev/null @@ -1,3 +0,0 @@ -File path is: /home/anna/.config/ocarina-test/test.file -File path is: /home/anna/.local/share/ocarina-test/test.file -File path is: /home/anna/.ocarina-test/test.file diff --git a/tests/file/io-debug.good b/tests/file/io-debug.good deleted file mode 100644 index e5cf4bd8..00000000 --- a/tests/file/io-debug.good +++ /dev/null @@ -1,7 +0,0 @@ -Writing data to file: /home/anna/.local/share/ocarina-test/test.io -Closing file -Reading file -File version is: 0 - Hello, World! - This is a multi-line file =) - a: 1, b: 2, c: 3, d: 4, e: 5 diff --git a/tests/file/open-debug.good b/tests/file/open-debug.good deleted file mode 100644 index 664bd6db..00000000 --- a/tests/file/open-debug.good +++ /dev/null @@ -1,19 +0,0 @@ - -ERROR: NOT_OPEN is not a legal OpenMode (/home/anna/.local/share/ocarina-test/test.0) -Test 0: Passed - -ERROR: File does not exist (/home/anna/.local/share/ocarina-test/test.1) -Test 1: Passed - -ERROR: Cannot write to legacy files (/home/anna/.ocarina-test/test.2) -Test 2: Passed - -Test 3a: Passed -ERROR: File is already open (/home/anna/.local/share/ocarina-test/test.3) -Test 3b: Passed - -Test 4a: Passed -Test 4b: Passed -Test 4c: Passed - -Test 5: Passed diff --git a/tests/file/open.good b/tests/file/open.good index f91e2afd..664bd6db 100644 --- a/tests/file/open.good +++ b/tests/file/open.good @@ -1,11 +1,15 @@ +ERROR: NOT_OPEN is not a legal OpenMode (/home/anna/.local/share/ocarina-test/test.0) Test 0: Passed +ERROR: File does not exist (/home/anna/.local/share/ocarina-test/test.1) Test 1: Passed +ERROR: Cannot write to legacy files (/home/anna/.ocarina-test/test.2) Test 2: Passed Test 3a: Passed +ERROR: File is already open (/home/anna/.local/share/ocarina-test/test.3) Test 3b: Passed Test 4a: Passed