diff --git a/.github/workflows/jq.yml b/.github/workflows/jq.yml new file mode 100644 index 00000000..887aa808 --- /dev/null +++ b/.github/workflows/jq.yml @@ -0,0 +1,39 @@ +name: jq + +on: + pull_request: + branches: + - main + paths: + - jq/* + +jobs: + test-jq-translation: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup Rust Toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + # TODO: this step takes ~2m, consider using https://github.com/marketplace/actions/cargo-install + - name: Install jaq + run: | + cargo install --locked --git https://github.com/01mf02/jaq + + - name: Expect unit test to fail + working-directory: jq + run: | + ! ./test-gilded-rose.sh + + - name: Expect texttest fixture output (aka 'verify') + working-directory: jq + run: | + jaq --arg days 31 -nr "$(cat gilded-rose.jq) $(cat texttest_fixture.jq)" | + diff - ../texttests/ThirtyDays/stdout.gr diff --git a/jq/texttest_fixture.jq b/jq/texttest_fixture.jq index 477147bb..12c08dc3 100644 --- a/jq/texttest_fixture.jq +++ b/jq/texttest_fixture.jq @@ -5,7 +5,7 @@ { name: "Aged Brie", sell_in: 2, quality: 0 }, { name: "Elixir of the Mongoose", sell_in: 5, quality: 7 }, { name: "Sulfuras, Hand of Ragnaros", sell_in: 0, quality: 80 }, - { name: "Sulfuras, Hand of Ragnaros", sell_in: 1, quality: 80 }, + { name: "Sulfuras, Hand of Ragnaros", sell_in: -1, quality: 80 }, { name: "Backstage passes to a TAFKAL80ETC concert", sell_in: 15, quality: 20 }, { name: "Backstage passes to a TAFKAL80ETC concert", sell_in: 10, quality: 49 }, { name: "Backstage passes to a TAFKAL80ETC concert", sell_in: 5, quality: 49 }, @@ -14,9 +14,9 @@ { items: ., day: 0 } | recurse(.day += 1 | .items = (.items | update_quality); .day < ($ARGS.named.days // 2 | tonumber)) | ( - "", (["-------- day ", (.day | tostring), " --------"] | add), ("name, sellIn, quality"), - (.items[] | [.name, .sell_in, .quality | tostring] | join(", ")) + (.items[] | [.name, .sell_in, .quality | tostring] | join(", ")), + "" ) )