diff --git a/src/frontend/gg-describe.cc b/src/frontend/gg-describe.cc index 0ed8b0cf..4528abd2 100644 --- a/src/frontend/gg-describe.cc +++ b/src/frontend/gg-describe.cc @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -67,7 +68,10 @@ int main( int argc, char * argv[] ) return EXIT_FAILURE; } - roost::path thunk_path { argv[ optind ] }; + std::string query = argv[ optind ]; + + roost::path thunk_path { query }; + cerr << thunk_path.string() << endl; if ( not roost::exists( thunk_path ) ) { thunk_path = gg::paths::blob( argv[ optind ] ); @@ -93,18 +97,23 @@ int main( int argc, char * argv[] ) } } - Thunk thunk = ThunkReader::read( thunk_path ); + if ( query[0] == 'V' ) { + ifstream value( thunk_path.string() ); + cout << value.rdbuf(); + } else { + Thunk thunk = ThunkReader::read( thunk_path ); - if ( print_executable_hash ) { - cout << thunk.executable_hash() << endl; - } + if ( print_executable_hash ) { + cout << thunk.executable_hash() << endl; + } - if ( print_command ) { - cout << command_str( thunk.function().args(), thunk.function().envars() ) << endl; - } + if ( print_command ) { + cout << command_str( thunk.function().args(), thunk.function().envars() ) << endl; + } - if ( not print_executable_hash and not print_command ) { - cout << protoutil::to_json( thunk.to_protobuf(), true ) << endl; + if ( not print_executable_hash and not print_command ) { + cout << protoutil::to_json( thunk.to_protobuf(), true ) << endl; + } } } catch ( const exception & e ) { diff --git a/tests/Makefile.am b/tests/Makefile.am index 57c264ce..5f3898f6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -30,7 +30,8 @@ dist_check_SCRIPTS = fetch-vectors.test \ model-ar.test model-ranlib.test model-strip.test \ model-ld.test gnu-hello.test mosh.test \ mosh-fewer-thunks.test fibonacci.test \ - sdk.test cleanup.test + sdk.test cleanup.test \ + describe-value.test thunk_roundtrip_SOURCES = thunk-roundtrip.cc sandbox_test_SOURCES = sandbox-test.cc diff --git a/tests/describe-value.test b/tests/describe-value.test new file mode 100755 index 00000000..ee3ae9bd --- /dev/null +++ b/tests/describe-value.test @@ -0,0 +1,20 @@ +#!/bin/bash -xe + +cd ${TEST_TMPDIR} + +export PATH=${abs_builddir}/../src/models:${abs_builddir}/../src/frontend:$PATH + +gg-init + +echo Hi > a.txt + +gg-collect a.txt + +hash=$(gg-hash a.txt) + +for i in $(seq 1 "${#hash}"); do + + diff a.txt <(gg-describe $(echo $hash | cut "-c1-${i}")) + +done +