//: Mu scenarios. This will get long, but these are the tests we want to //: support in this layer. //: You can use variable names in scenarios, but for the most part we'll use //: raw location numbers, because that lets us make assertions on memory. //: Tests should avoid abstraction as far as possible. :(scenarios run_mu_scenario) :(scenario scenario_block) scenario foo [ run [ 1:number <- copy 13:literal ] memory-should-contain [ 1 <- 13 ] ] # checks are inside scenario :(scenario scenario_multiple_blocks) scenario foo [ run [ 1:number <- copy 13:literal ] memory-should-contain [ 1 <- 13 ] run [ 2:number <- copy 13:literal ] memory-should-contain [ 1 <- 13 2 <- 13 ] ] :(scenario scenario_check_memory_and_trace) scenario foo [ run [ 1:number <- copy 13:literal trace [a], [a b c] ] memory-should-contain [ 1 <- 13 ] trace-should-contain [ a: a b c ] trace-should-not-contain [ a: x y z ] ] //:: Core data structure :(before "End Types") struct scenario { string name; string to_run; }; :(before "End Globals") vector<scenario> Scenarios; //:: Parse the 'scenario' form. //: Simply store the text of the scenario. :(before "End Command Handlers") else if (command == "scenario") { Scenarios.push_back(parse_scenario(in)); } :(code) scenario parse_scenario(istream& in) { //? cerr << "parse scenario\n"; //? 1 scenario result; result.name = next_word(in); //? cerr << "scenario: " << result.name << '\n'; //? 2 skip_whitespace_and_comments(in); assert(in.peek() == '['); // scenarios are take special 'code' strings so we need to ignore brackets // inside comments result.to_run = slurp_quoted(in); // delete [] delimiters assert(result.to_run.at(0) == '['); result.to_run.erase(0, 1); //? cerr << (int)result.to_run.at(SIZE(result.to_run)-1) << '\n'; //? 1 assert(result.to_run.at(SIZE(result.to_run)-1) == ']'); result.to_run.erase(SIZE(result.to_run)-1); return result; } :(scenario read_scenario_with_bracket_in_comment) scenario foo [ # ']' in comment 1:number <- copy 0:literal ] +run: 1:number <- copy 0:literal :(scenario read_scenario_with_bracket_in_comment_in_nested_string) scenario foo [ 1:address:array:character <- new [# not a comment] ] +run: 1:address:array:character <- new [# not a comment] //:: Run scenarios when we run 'mu test'. //: Treat the text of the scenario as a regular series of instructions. :(before "End Tests") time_t mu_time; time(&mu_time); cerr << "\nMu tests: " << ctime(&mu_time); for (long long int i = 0; i < SIZE(Scenarios); ++i) { //? cerr << Passed << '\n'; //? 1 //? cerr << i << ": " << Scenarios.at(i).name << '\n'; //? 6 run_mu_scenario(Scenarios.at(i)); if (Passed) cerr << "."; } //: Convenience: run a single named scenario. :(after "Test Runs") for (long long int i = 0; i < SIZE(Scenarios); ++i) { if (Scenarios.#!/bin/bash # # This script searches image files in a directory, opens them all with sxiv # and sets the first argument to the first image displayed by sxiv. # # This is supposed to be used in rifle.conf as a workaround for the fact that # sxiv takes no file name arguments for the first image, just the number. # Copy this file somewhere into your $PATH and add this at the top of rifle.conf: # # mime ^image, has sxiv, X, flag f = path/to/this/script -- "$@" # [ "$1" == '--' ] && shift target="$(realpath -s "$1")" function listfiles { find -L "$(dirname "$target")" -maxdepth 1 -type f -iregex \ '.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z } count="$(listfiles | grep -m 1 -Zznx "$target" | cut -d: -f1)" if [ -n "$count" ]; then listfiles | xargs -0 sxiv -n "$count" -- else sxiv -- "$@" # fallback fi