diff options
author | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2015-11-27 14:21:01 +0000 |
---|---|---|
committer | Tiago Gomes <tiago.gomes@codethink.co.uk> | 2015-12-02 12:19:29 +0000 |
commit | 0d24e380ff394782358da99b776a187d402142e9 (patch) | |
tree | 895f2fe3efe4c524cd6ed0f65a4ce7c24c0cb267 /scripts/test-shell.c | |
parent | c8f97d36441ce8e0bd18feba8073f32a2b1c4628 (diff) | |
download | morph-0d24e380ff394782358da99b776a187d402142e9.tar.gz |
Convert last cmdtests to yarns
The conversion was made so that the build command was used instead of
the build-morphology command.
Change-Id: I67c43d765ed603ecdd806bc649815526243b7b87
Diffstat (limited to 'scripts/test-shell.c')
-rw-r--r-- | scripts/test-shell.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/scripts/test-shell.c b/scripts/test-shell.c index 963d128c..a57fddce 100644 --- a/scripts/test-shell.c +++ b/scripts/test-shell.c @@ -163,6 +163,9 @@ int run_commands(FILE *cmdstream){ ret = 1; break; } + } else if (strstr(line, "printvar ") == line) { + char const *var = line + sizeof("printvar ") - 1; + fprintf(stdout, "%s\n", getenv(var)); } else if (strstr(line, "create file ") == line) { char const *filename = line + sizeof("create file ") -1; FILE *outfile = fopen(filename, "w"); @@ -178,6 +181,12 @@ int run_commands(FILE *cmdstream){ break; } fclose(outfile); + } else if (strstr(line, "file exists ") == line) { + char const *filename = line + sizeof("file exists ") -1; + fprintf(stderr, "FILENAME: %s\n", filename); + struct stat st; + int result = stat(filename, &st); + return result != 0; } else if (line[0] == '#' || strstr(line, "set ") == line) { /* Comments and set commands are ignored */ continue; @@ -201,7 +210,8 @@ int main(int argc, char *argv[]) { FILE *cmdstream = fopen(argv[1], "r"); return run_commands(cmdstream); } else { - fprintf(stderr, "Usage: %s -c COMMAND|%s SCRIPT\n", argv[0], argv[0]); + fprintf(stderr, "Usage: %s -x -c COMMAND|%s SCRIPT\n", + argv[0], argv[0]); return 1; } } |