History

tests2: cleanup

- remove -norunsrc switch Meaning and usage (-run -norun...???) look sort of screwed. Also general usefulness is unclear, so it was actually to support exactly one (not even very interesting) test This partially reverts e31579b0769e1f9c0947d12e83316d1149307b1a

grischka committed 12 years ago

Commit f90bad01 parent 76accfb5 files · +26 −32Browse files

Unified · Split

5 files
  1. libtcc.c +1 −8
  2. tcc.c +0 −1
  3. tests/tests2/31_args.c +1 −1
  4. tests/tests2/31_args.expect +5 −6
  5. tests/tests2/Makefile +19 −16
libtcc.c+1−8
@@ -1666,7 +1666,6 @@ enum { · 1665 unmodified lines
1666 TCC_OPTION_pedantic,1666 TCC_OPTION_pedantic,
1667 TCC_OPTION_pthread,1667 TCC_OPTION_pthread,
1668 TCC_OPTION_run,1668 TCC_OPTION_run,
1669 TCC_OPTION_norunsrc,
1670 TCC_OPTION_v,1669 TCC_OPTION_v,
1671 TCC_OPTION_w,1670 TCC_OPTION_w,
1672 TCC_OPTION_pipe,1671 TCC_OPTION_pipe,
@@ -1709,7 +1708,6 @@ static const TCCOption tcc_options[] = { · 36 unmodified lines
1709 { "pedantic", TCC_OPTION_pedantic, 0},1708 { "pedantic", TCC_OPTION_pedantic, 0},
1710 { "pthread", TCC_OPTION_pthread, 0},1709 { "pthread", TCC_OPTION_pthread, 0},
1711 { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },1710 { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
1712 { "norunsrc", TCC_OPTION_norunsrc, 0 },
1713 { "rdynamic", TCC_OPTION_rdynamic, 0 },1711 { "rdynamic", TCC_OPTION_rdynamic, 0 },
1714 { "r", TCC_OPTION_r, 0 },1712 { "r", TCC_OPTION_r, 0 },
1715 { "s", TCC_OPTION_s, 0 },1713 { "s", TCC_OPTION_s, 0 },
@@ -1748,7 +1746,6 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 32 unmodified lines
1748 const TCCOption *popt;1746 const TCCOption *popt;
1749 const char *optarg, *r;1747 const char *optarg, *r;
1750 int run = 0;1748 int run = 0;
1751 int norunsrc = 0;
1752 int pthread = 0;1749 int pthread = 0;
1753 int optind = 0;1750 int optind = 0;
1754 1751
@@ -1761,8 +1758,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 6 unmodified lines
1761 r = argv[optind++];1758 r = argv[optind++];
1762 if (r[0] != '-' || r[1] == '\0') {1759 if (r[0] != '-' || r[1] == '\0') {
1763 /* add a new file */1760 /* add a new file */
1764 if (!run || !norunsrc)1761 dynarray_add((void ***)&s->files, &s->nb_files, tcc_strdup(r));
1765 dynarray_add((void ***)&s->files, &s->nb_files, tcc_strdup(r));
1766 if (run) {1762 if (run) {
1767 optind--;1763 optind--;
1768 /* argv[0] will be this file */1764 /* argv[0] will be this file */
@@ -1888,9 +1884,6 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 119 unmodified lines
1888 tcc_set_options(s, optarg);1884 tcc_set_options(s, optarg);
1889 run = 1;1885 run = 1;
1890 break;1886 break;
1891 case TCC_OPTION_norunsrc:
1892 norunsrc = 1;
1893 break;
1894 case TCC_OPTION_v:1887 case TCC_OPTION_v:
1895 do ++s->verbose; while (*optarg++ == 'v');1888 do ++s->verbose; while (*optarg++ == 'v');
1896 break;1889 break;
tcc.c+0−1
@@ -69,7 +69,6 @@ static void help(void) · 68 unmodified lines
69 " -Bdir use 'dir' as tcc internal library and include path\n"69 " -Bdir use 'dir' as tcc internal library and include path\n"
70 " -MD generate target dependencies for make\n"70 " -MD generate target dependencies for make\n"
71 " -MF depfile put generated dependencies here\n"71 " -MF depfile put generated dependencies here\n"
72 " -norunsrc Do not compile the file which is the first argument after -run.\n"
73 );72 );
74}73}
75 74
tests/tests2/31_args.c+1−1
@@ -5,7 +5,7 @@ int main(int argc, char **argv) · 4 unmodified lines
5 int Count;5 int Count;
6 6
7 printf("hello world %d\n", argc);7 printf("hello world %d\n", argc);
8 for (Count = 0; Count < argc; Count++)8 for (Count = 1; Count < argc; Count++)
9 printf("arg %d: %s\n", Count, argv[Count]);9 printf("arg %d: %s\n", Count, argv[Count]);
10 10
11 return 0;11 return 0;
tests/tests2/31_args.expect+5−6
@@ -1,7 +1,6 @@
1hello world 61hello world 6
2arg 0: 31_args.c2arg 1: arg1
3arg 1: -3arg 2: arg2
4arg 2: arg14arg 3: arg3
5arg 3: arg25arg 4: arg4
6arg 4: arg36arg 5: arg5
7arg 5: arg4
tests/tests2/Makefile+19−16
@@ -46,9 +46,11 @@ TESTS = \ · 45 unmodified lines
46 27_sizeof.test \46 27_sizeof.test \
47 28_strings.test \47 28_strings.test \
48 29_array_address.test \48 29_array_address.test \
49 30_hanoi.test \
49 31_args.test \50 31_args.test \
50 32_led.test \51 32_led.test \
51 33_ternary_op.test \52 33_ternary_op.test \
53 34_array_assignment.test \
52 35_sizeof.test \54 35_sizeof.test \
53 36_array_initialisers.test \55 36_array_initialisers.test \
54 37_sprintf.test \56 37_sprintf.test \
@@ -60,6 +62,7 @@ TESTS = \ · 5 unmodified lines
60 43_void_param.test \62 43_void_param.test \
61 44_scoped_declarations.test \63 44_scoped_declarations.test \
62 45_empty_for.test \64 45_empty_for.test \
65 46_grep.test \
63 47_switch_return.test \66 47_switch_return.test \
64 48_nested_break.test \67 48_nested_break.test \
65 49_bracket_evaluation.test \68 49_bracket_evaluation.test \
@@ -81,31 +84,31 @@ TESTS = \ · 15 unmodified lines
81# 34_array_assignment.test -- array assignment is not in C standard84# 34_array_assignment.test -- array assignment is not in C standard
82# 46_grep.test -- does not compile even with gcc85# 46_grep.test -- does not compile even with gcc
83 86
87SKIP = 30_hanoi.test 34_array_assignment.test 46_grep.test
88
84# some tests do not pass on all platforms, remove them for now89# some tests do not pass on all platforms, remove them for now
85ifeq ($(TARGETOS),Darwin)90ifeq ($(TARGETOS),Darwin)
86 TESTS := $(filter-out 40_stdio.test,$(TESTS))91 SKIP += 40_stdio.test
87endif92endif
88ifdef CONFIG_WIN3293ifdef CONFIG_WIN32
89 TESTS := $(filter-out 24_math_library.test 28_strings.test,$(TESTS))94 SKIP += 24_math_library.test # don't have round()
95 SKIP += 28_strings.test # don't have r/index() / strings.h
90endif96endif
91 97
98# Some tests might need arguments
99ARGS =
10031_args.test : ARGS = arg1 arg2 arg3 arg4 arg5
101
102all test: $(filter-out $(SKIP),$(TESTS))
103
92%.test: %.c %.expect104%.test: %.c %.expect
93 @echo Test: $*...105 @echo Test: $*...
94 @if [ "x`echo $* | grep args`" != "x" ]; \
95 then $(TCC) $< -norunsrc -run $(notdir $<) - arg1 arg2 arg3 arg4 >$*.output 2>&1; \
96 else $(TCC) -run $< >$*.output 2>&1; \
97 ($(TCC) -o $*.exe $< && ./$*.exe) >$*.output2 2>&1; \
98 fi || true
99 @if diff -bu $(<:.c=.expect) $*.output ; \
100 then rm -f $*.output; \
101 else exit 1; \
102 fi
103 @if test -f $*.output2; then if diff -bu $(<:.c=.expect) $*.output2 ; \
104 then rm -f $*.output2; \
105 else exit 1; \
106 fi; fi
107 106
108all test: $(TESTS)107 @$(TCC) -run $< $(ARGS) >$*.output 2>&1 || true
108 @diff -bu $*.expect $*.output && rm -f $*.output
109
110 @($(TCC) $< -o $*.exe && ./$*.exe $(ARGS)) >$*.output2 2>&1 || true
111 @diff -bu $*.expect $*.output2 && rm -f $*.output2 $*.exe
109 112
110clean:113clean:
111 rm -vf fred.txt *.output* *.exe114 rm -vf fred.txt *.output* *.exe

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t